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

Help with platformstand when touching a part?

local h = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")

script.Parent.Touched:connect(function()
	h.PlatformStand = true
end)

There is a localscript inside the part and thats the script in it. i don't know how to activate platformstand though (its a property of humanoid in the player [at least in test mode])

2 answers

✓ Accepted answer

Events can pass arguments to their connected functions. Touched passes the part that touched as an argument. Example:

script.Parent.Touched:connect(function(part) --"part" will be the part that touched script.Parent.
	part:Destroy()
end)

To apply it to your script:

--We won't need a LocalScript for this. Put a server script in the part.
script.Parent.Touched:connect(function(part) --part is what touched script.Parent.
	local humanoid = part.Parent:FindFirstChild("Humanoid") --Try to find a humanoid in the part's Parent.
	if humanoid and not humanoid.PlatformStand then --If we do, and it's not PlatformStanding
		humanoid.PlatformStand = true --Make it PlatformStand
	end
end)

If you're going to use:

local h = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")

script.Parent.Touched:connect(function()
    h.PlatformStand = true
end)

I believe it would be a localscript, if it's already a localscript, try adding the variable "h" inside of the function.

script.Parent.Touched:connect(function()
    local h = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
    h.PlatformStand = true
end)

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