Skip to content

Commit

Permalink
Disabled ball throwing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewens committed Aug 31, 2023
1 parent db84927 commit 512ae8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
5 changes: 1 addition & 4 deletions src/ServerScriptService/Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Server:initialize(): nil
end
end)
end
function Server:newBall(position: Vector3, velocity: Vector3, color: Color3): BasePart
function Server:newBall(position: Vector3, color: Color3): BasePart
--[[
Create a new Ball RBX Instance and add it to the Server, to be put into the QuadTree
]]
Expand All @@ -149,9 +149,6 @@ function Server:newBall(position: Vector3, velocity: Vector3, color: Color3): Ba
table.insert(self._Balls, Ball)
Ball.Parent = workspace

-- I AM SPEED
Ball.Velocity = velocity

return Ball
end
function Server:clearBalls(): boolean
Expand Down
28 changes: 3 additions & 25 deletions src/StarterPack/Ball/ThrowBall.client.lua
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)

0 comments on commit 512ae8f

Please sign in to comment.