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

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

Asked by
bossay6 62
6 years ago
Edited 6 years ago
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

0
is this in a local script? if not then .LocalPlayer wont work Worthy0ne 68 — 6y
0
If they remove the question, they do it for a reason. https://scriptinghelpers.org/help/how-post-good-questions-answers hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by
commag 228 Moderation Voter
6 years ago

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.

0
i put it in localscript it doesn't kill the player bossay6 62 — 6y
0
you want it to kill the player?? Where does it say that? outlook1234567890 115 — 6y
0
line 4 bossay6 62 — 6y
Ad
Log in to vote
0
Answered by
Viking359 161
6 years ago

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.

Answer this question