Easy mate, no worries.
Where you went wrong:
You're trying to access localplayer through a script, yet that's only possible with localscripts.
Instead, you can get the player from character through "game.Players:GetPlayerFromCharacter()".
A character is a model containing the humanoid, arms, legs, torso, and scripts of a player's character. Initially this property is set to nil, and is set when the player's character spawns.
The hit in a function using the touched event will be inside the character, so therefor, the character itself is the parent of the hit.
The fixed script would look like this:
workspace:FindFirstChild("SlideTrigger").Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
print("Touched, now sitting")
workspace[player.Name].Humanoid.Sit = true
end)
A more simpler script would be like this
workspace:FindFirstChild("SlideTrigger").Touched:connect(function(hit)
print("Touched, now sitting")
hit.Parent:WaitForChild("Humanoid").Sit = true
end)
1 comment
Yeah, works better that way since those free-sit physics doesn't appear.