-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disabled ball throwing functionality
- Loading branch information
Showing
2 changed files
with
4 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
-- dependencies | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
local Players = game:GetService("Players") | ||
|
||
local RemoteEvents = ReplicatedStorage.RemoteEvents | ||
local Player = Players.LocalPlayer | ||
local Tool = script.Parent | ||
|
||
local Mouse = Player:GetMouse() | ||
local Handle = Tool:WaitForChild("Handle") | ||
|
||
-- constant | ||
local BALL_SPEED = 0 -- it's set to 0 so you can drop balls on top of each other, but you can change it if you'd like :) | ||
local COLOR = BrickColor.Random() | ||
local COLOR = BrickColor.Random().Color | ||
|
||
-- initialize | ||
local function throwBall() | ||
--[[ | ||
Throws a ball toward player's 3d mouse position. | ||
Balls are initialized on the server, so we fire a RemoteEvent to make a new ball. | ||
]] | ||
|
||
-- get character root part (return if nil) | ||
local RootPart | ||
do | ||
local Char = Player.Character | ||
if Char == nil then | ||
return | ||
end | ||
|
||
RootPart = Char:FindFirstChild("HumanoidRootPart") | ||
if RootPart == nil then | ||
return | ||
end | ||
end | ||
|
||
-- throw a ball | ||
local direction = (Mouse.Hit.Position - RootPart.Position).Unit | ||
RemoteEvents.NewBall:FireServer(Handle.Position, direction * BALL_SPEED, COLOR.Color) | ||
-- make a ball at handle position | ||
RemoteEvents.NewBall:FireServer(Handle.Position, COLOR) | ||
end | ||
Tool.Activated:Connect(throwBall) |