Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is this script only working when it is inside a local script but not inside a server script?

Asked by 5 years ago
script.Parent.Touched:Connect(function(Hit)

wait(0.5)

Hit.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)

end)

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

the parent of the touched function, needs to see if it really is a player.

Try this

script.Parent.Touched:Connect(function(player)
local humanoid = player.Parent:FindFirstChild("Humanoid")
if humanoid~= nil then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)
Ad
Log in to vote
0
Answered by 5 years ago

You Should use:

Hit.Parent.Humanoid.Jump = true

Do not forgot to check if the humanoid Exists, or else the script will throw lots of errors!

script.Parent.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChildOfClass('Humanoid') ~= nil then --Checks if the Humanoid Exists
        Hit.Parent.Humanoid.Jump = true --Makes the Character Jump
    end
end)

This is optional, you can Add a Debounce to the script:

local Debounce = false
script.Parent.Touched:Connect(function(Hit)
    if not Debounce and Hit.Parent:FindFirstChildOfClass('Humanoid') ~= nil then --Checks if the Humanoid Exists
        Debounce = true
        Hit.Parent.Humanoid.Jump = true --Makes the Character Jump
        wait(1) --Cooldown
        Debounce = false
    end
end)
0
But thats what i told him to do ;( JuuzouBlitz 75 — 5y
0
sorry i didn't notice it, i started writing it.. probably at same time as you :P FullMetalEdward45221 106 — 5y
0
Didn't work. Checing the humanoid has nothing to do with it. Thepoint13 99 — 5y

Answer this question