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

Local Force Sit Script Singleplayer?

Asked by 3 years ago

Trying to make a force sit script for a single player game once the player has joined. I have tried using a server script aswell, and the "done" does not print, no error seems to be shown.. is this my fault, or is this method non-existant?

game.Players.PlayerAdded:Connect(function(plrn)
    local holder = plrn.Name
    wait(1)
    script.Parent:Sit(game.Workspace[holder].Character:WaitForChild('Humanoid'))
    print('done')
end)

2 answers

Log in to vote
0
Answered by 3 years ago

You tried to get the character.... of a character.

"game.Workspace[holder].Character"

Remove the .Character and see if it works.

Ad
Log in to vote
0
Answered by 3 years ago

Here's how you could do this with a local script:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

hum.Sit = true

But if you wanted to do it with a server script (which I recommend, even in a single player server):

game.Players.PlayerAdded:Connect(function(plyr)
    plyr.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild("Humanoid")
        wait(1)
        hum.Sit = true
    end)
end)

I noticed whenever testing these scripts, the sitting animation had yet to load, and would not load afterwards.

Answer this question