I added a button in my game and when you click it, you will be launched forwards and the player will sit. In the button I have this script:
local button = script.Parent
local boing = button.Boing -- Sound Effect
local cannonBall = game.ReplicatedStorage.CannonBall
local d = false
button.MouseButton1Click:Connect(function()
if d then return end
button.Boing:Play() -- Boing Sound plays
cannonBall:FireServer() -- The Script that makes the player launch forwards starts
d = true
wait(2.5) -- delay
d = false
end)
Here is the Launch script inside StarterCharacterScripts:
local cannonBall = game.ReplicatedStorage.CannonBall
local char = script.Parent
cannonBall.OnServerEvent:Connect(function()
local hum = char.Humanoid
local HRP = char.HumanoidRootPart
hum.Jump = true
wait(0.2)
HRP.Velocity = HRP.CFrame.LookVector * 100
hum.Sit = true
end)
Whenever I click the button, I do jump in the air and sit, but I never get launched forwards. For some reason, the velocity thing isn't working. Please tell me why.
Thx to the people who will help! :)
