What is wrong with this code

I am trying to make it when you touch the object you fall over but this code wont work and i don’t see anything wrong with it


When i type out if game.players:GetPlayersFromChararcter(hit.parent) the parent doesn’t give me a auto fill.

Thanks

1 Like

So first off, you should try capitalizing “Humanoid”. Also, just in case, use :WaitForChild('Humanoid')

Capitalization is important, and when we use WaitForChild it’s just to be sure we don’t try and find a descendent of an object that hasn’t loaded just yet. Here is your new script, I hope it helps!

game.Workspace.flop.Touched:Connect(function(hit)
   if game.Players:GetPlayerFromCharacter(hit.Parent) then
      hit.Parent:WaitForChild('Humanoid').Sit = true
   end
end)
2 Likes

Why did you put true() it should just be true

1 Like
game:GetService("Workspace").Flop.Touched:Connect(function(hit)
	if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
		local humanoid = hit.Parent:WaitForChild("Humanoid")
		if humanoid then
			humanoid.Sit = true
		end
	end
end)

I tested this and it works

1 Like

Thank you so much. Took me 1hour trying to figure it out. Do you know why it didn’t fully work? Because i didn’t say wait for humanoid?

Possibly both WaitForChild() and because Humanoid wasn’t capitalized.

1 Like