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

Why does this not sit my character?

Im trying to make a script where it finds yourplayer then sits you down. But its not working in studio. This script is a localscript

player_name=game.Players.LocalPlayer.Name
character=workspace:findFirstChild(player_name)

while true do
	character.Humanoid.Sit = true
	wait(0.5)
end

2 answers

✓ Accepted answer

Local Script

repeat wait() until game.Players.LocalPlayer.Character

while true do
game.Players.LocalPlayer.Character.Humanoid.Sit = true
wait(.5)
end

Well, we don't need the player name for this example. So we can rule that out. We can also create a short reference to the character by indexing LocalPlayer with "Character".

Here, try this:

-- Get the local player (should be in a local script)
local Client = game:GetService'Players'.LocalPlayer

 -- just in case the character needs time to load
local Character = Client.Character or Client.CharacterAdded:wait()

while true do
	local Human = Character:FindFirstChild'Humanoid'
	if Human then
		Human.Sit = true
	end
	wait(0.5)
end

Let me know if you have any questions.

2 comments

0

It does not work online or in studio :(

0

Works fine for me, remember to put this in a local script.

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