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

I need help with this obby spawn script thing. It is not working. Help please?

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded;wait()
local humanoid = char:FindFirstChild("Humanoid")
humanoid.Health = 0
humanoid.Died:connect(function()
    wait(4)
    if plr.leaderstats.Stage.Value == 1 then
        char.Torso.CFrame = CFrame.new(workspace.Spawns.Stage1Spawn.Position) + Vector3.new(0,2,0)
    end
end)

00:18:53.756 - ServerScriptService.StageSpawning:2: attempt to index local 'plr' (a nil value)

also, stop removing my questions i just want this script fixed then i will stop

2 comments

0

is this in a local script? if not then .LocalPlayer wont work

0

If they remove the question, they do it for a reason. https://scriptinghelpers.org/help/how-post-good-questions-answers

2 answers

Okay, so, if this isn't in a local script, it won't work. if it isn't in a local script, I advise you put it in one.

3 comments

0

i put it in localscript it doesn't kill the player

0

you want it to kill the player?? Where does it say that?

0

line 4

You should use break joints instead of changing the health

local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded;wait()
local humanoid = char:FindFirstChild("Humanoid")
plr:BreakJoints()
humanoid.Died:Connect(function()
    wait(4)
    if plr.leaderstats.Stage.Value == 1 then
        char.Torso.CFrame = CFrame.new(game.Workspace.Spawns.Stage1Spawn.Position) + Vector3.new(0,2,0)
    end
end)

You should just use the exact coordinates of the spawn if the game.Workspace section doesnt work. Also, use :Connect instead of :connect and game.Workspace rather than .workspace.

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