I’m currently making a grenade for my game. When you click with the tool open, the grenade just shoots up into the sky, and doesn’t come down.
Video: Video
I’ve looked up YouTube videos, and on Developer Hub. I’ve also tried fixing things with the output.
LocalScript
local plr = game:GetService("Players").LocalPlayer
local reloadTime = 2
local dur = 0
local mouseDown = false
local startedDown = 0
local handle = script.Parent:WaitForChild("Handle")
local throwSound = handle:WaitForChild("ThrowSound")
tool.Enabled = true
local preventRecast = false
local rE = script.Parent:WaitForChild("Throw")
--local GUI = script.Parent:WaitForChild("GUI").Value
--local Frame_meter = GUI.Frame.Meter
tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
--
-- if not tool.Enabled then
-- return
-- end
if preventRecast then
print"PR is on. will return"
return
else
mouseDown = true
startedDown = tick()
end
-- while mouseDown == true do
-- Frame_meter.Size = Frame_meter.Size + UDim2.new(0,0,.1,0)
-- wait(.1)
-- end
end)
mouse.Button1Up:connect(function()
mouseDown = false
tool.Enabled = false
if preventRecast then
return
else
preventRecast = true
print"turning PR on"
delay(reloadTime, function()
preventRecast = false
end)
dur = tick() - startedDown
-- Frame_meter.Size = UDim2.new(1,0,0,0)
print("Mouse was held for : "..dur.." seconds")
if dur > .8 then
dur = .8
elseif dur < .4 then
dur = .4
end
throwSound:Play()
rE:FireServer(dur)
-- if game.JobId ~= "" then
-- tool:Destroy()
-- end
wait(reloadTime)
tool.Enabled = true
end
end)
end)
Script that fires server
local rE = script.Parent:WaitForChild("Throw")
rE.OnServerEvent:Connect(function(plr, dur)
local clone = toclone:Clone()
clone.Parent = workspace
clone.Position = plr.Character.Head.Position + (plr.Character.Head.CFrame.lookVector * 4)
local BF = Instance.new("BodyForce", clone)
BF.Force = plr.Character.Head.CFrame.lookVector * 1750 *dur + Vector3.new(0, 4480*dur, 0)
clone.Name = plr.Name.."Grenade"
clone.CanCollide = true
wait(.4)
clone.BodyForce:Destroy()
wait(1)
clone.Armed:Play()
clone.Anchored = true
wait(.2)
local e = Instance.new("Explosion")
e.ExplosionType = Enum.ExplosionType.NoCraters
e.BlastPressure = 100
e.BlastRadius = 16
e.Position = clone.Position
e.Parent = game.Workspace
clone.Transparency = 1
clone.BoomSound:Play()
--to let the sound play
wait(3)
clone:Destroy()
end)
Help?