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

My checkpoint system sets the level of the player to 0 for no apparent reason?

Asked by 5 years ago
01local DataStoreService = game:GetService("DataStoreService")
02local myDataStore = DataStoreService:GetDataStore("myDataStore")
03 
04game.Players.PlayerAdded:Connect(function(player)
05    local char = player.Character or player.CharacterAdded:wait()
06    local ack = Instance.new("IntValue")
07    ack.Name = "leaderstats"
08    local ack2 = Instance.new("IntValue")
09    ack2.Name = "Stage"
10    ack2.Value = 1
11    ack2.Parent = ack
12    ack.Parent = player
13    local ack3 = Instance.new("IntValue", ack)
14    ack3.Name = "Prestige"
15    ack3.Value = 0
View all 76 lines...

If a player has data they will spawn in the right place after dying once. If a player does not have data they will be on stage 0 and fall to their death infinitely.

On line 40: Attempt to index nil with 'CFrame'

1
Not all characters have uppertorso. Use HumanoidRootPart instead. voidofdeathfire 148 — 5y
0
Didn't work and it had the same error jalbraek 29 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

local char = player.Character

That's what line 5 should be.

char:WaitForChild("HumanoidRootPart").CFrame = sl.CFrame + Vector3.new(0,3,0)

That's what line 40 should be.

0
It didn't work it had the same error: Line 40 : attempt to index nil with 'CFrame' jalbraek 29 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
01local DataStoreService = game:GetService("DataStoreService")
02local myDataStore = DataStoreService:GetDataStore("myDataStore")
03 
04game.Players.PlayerAdded:Connect(function(player)
05    local char = player.Character or player.CharacterAdded:wait()
06    local ack = Instance.new("IntValue")
07    ack.Name = "leaderstats"
08    local ack2 = Instance.new("IntValue")
09    ack2.Name = "Stage"
10    ack2.Value = 1
11    ack2.Parent = ack
12    ack.Parent = player
13    local ls = player.leaderstats
14    ls:WaitForChild("Stage").Value = 1
15    local ack3 = Instance.new("IntValue", ack)
View all 93 lines...

This is the fixed code.

Answer this question