cozfl
(Luke)
May 19, 2025, 2:14pm
1
This is the script I have, its just after the leaderstats script and just before the datastore part of my datastore script
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
stage.Value = 0
end)
end)
Any help will be greatly appreciated!
why won’t you do it on the client and a remoteevent
seems more straightforward
Have you tried printing stage.Value to see if it did actually change?
And if there’s any other relevant code, please provide it.
2112Jay
(2112Jay)
May 19, 2025, 2:25pm
4
Luke:
stage.Value
I’m guessing you defined stage as stage.Value up top.
cozfl
(Luke)
May 19, 2025, 2:34pm
5
stage is defined as an instance.new and the "stage.Value = " part works as i’ve used it in another script
cozfl
(Luke)
May 19, 2025, 2:37pm
6
Stage.Value doesnt print, so its an issue with the dying part
Then, how is the player dying? I don’t see any problem with your code.
Are you destroying the character/humanoid?
cozfl
(Luke)
May 19, 2025, 2:42pm
8
No, theres no indirect code to kill the player its just supposed to detect when the player has died
Give us the full script please. It’s like:
Yo guys why my script doesn’t work?
Variable.Value = 50
1 Like
I didn’t mean “indirect”.
I meant How are you killing the player? Where?
Provide any other related script if you need help; I (We) can’t just keep assuming and receiving No, It’s not, it doesn’t …
Agree on this.
cozfl
(Luke)
May 19, 2025, 2:46pm
11
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Parent = leaderstats
stage.Value = 0
local bstage = Instance.new("IntValue")
bstage.Name = "BestStage"
bstage.Parent = leaderstats
bstage.Value = 0
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
stage.Value = 0
print(stage.Value)
end)
end)
I think this is all the relevant parts to this
Because you waited for Character to spawn at the start. If you’ll remove the first Player.CharacterAdded:Wait() it will work.
1 Like
2112Jay
(2112Jay)
May 19, 2025, 2:49pm
13
Luke:
stage.Value = 0
Over the top of all this add; local stage = nil
Then don’t use a local on local stage = Instance.new(“IntValue”)
local stage = nil
game.Players.PlayerAdded:Connect(function(player)
--
--
stage = Instance.new("IntValue")
--
technically it will work, just not the first time but the second.
1 Like
cozfl
(Luke)
May 19, 2025, 2:50pm
15
I just checked that and yeah you’re right lol, it does work on the 2nd respawn
Please look at the post before giving your solution. Check if anyone answered it already.
Mark @Fan_Len4ika1Tvink123 as solution If your problem was fixed.
Why? What’s this going to do? ( actually curious )
cozfl
(Luke)
May 19, 2025, 2:52pm
18
I did not realise it was gonna be that simple, thank you!
1 Like
I have no idea but the Stage variable will be replaced when a new Player joins, so this isn’t a solution, but it adds more problems
1 Like
2112Jay
(2112Jay)
May 19, 2025, 2:57pm
20
It should have work the way it was… I was setting up a test.
I should have seen the Player.CharacterAdded:Wait() was missing.
1 Like