Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

script.Parent.Touched:Connect(function(Hit)

wait(0.5)

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

end)

2 answers

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)

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)

3 comments

0

But thats what i told him to do ;(

0

sorry i didn't notice it, i started writing it.. probably at same time as you :P

0

Didn't work. Checing the humanoid has nothing to do with it.

This discussion is preserved as it was. New answers, comments, and votes are closed.