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

Help with platformstand when touching a part?

Asked by 9 years ago
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

Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

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)
Ad
Log in to vote
0
Answered by 9 years ago

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)

Answer this question