-
What do you want to achieve?
I want the brick to be thrown. -
What is the issue?
The player won’t let go of the brick.
local db = false
local direction
local debris = game:GetService("Debris")
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, mousePos)
direction = mousePos
end)
script.Parent.Activated:Connect(function()
if not db then
db = true
--Play Animation--
local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local throwAnim = humanoid:LoadAnimation(script.Throw)
throwAnim:Play()
wait(.5)
--Throw the ball--
script.Parent.Handle.Throw:Play()
script.Parent.Handle.Transparency = 1
local ball = game.ReplicatedStorage.Handle
ball:Clone()
ball.CFrame = CFrame.new(script.Parent.Handle.Position + script.Parent.Handle.CFrame.LookVector * 3, direction)
--Trail--
local attachment0 = Instance.new("Attachment", ball); attachment0.Position = Vector3.new(-.5,0,0); attachment0.Orientation = Vector3.new(0,180,0)
local attachment1 = Instance.new("Attachment", ball); attachment1.Position = Vector3.new(.5,0,0); attachment1.Orientation = Vector3.new(0,0,0)
local trail = Instance.new("Trail", ball); trail.Attachment0 = attachment0; trail.Attachment1 = attachment1
--Body Velocity--
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.P = 3000
local ori = 0
spawn(function()
while wait() do
ori = ori - .1
ball.CFrame = ball.CFrame + ball.CFrame.lookVector * 4
ball.Orientation = Vector3.new(ball.Orientation.X + ori, ball.Orientation.Y, ball.Orientation.Z)
end
end)
--Touch Function--
ball.Touched:Connect(function(hit)
ball:Destroy()
local player = game.Players:GetPlayersFromCharacter(hit.Parent)
if player then
local char = player.Character
local humanoid = char:FindFirstChild("Humanoid")
humanoid.Health = humanoid.Health - 20
humanoid.PlatformStand = true
end
debris:AddItem(5)
end)
script.Parent.Handle.Transparency = 0
wait(.5)
db = false
end
end)