You forgot to use a function and listener for this. Codes without a function/listener will only run once when the server started up. Therefore, it will cache the player's rebirth stat.
There are 3 types of functions.
This is the most common one. (Unrecommended)
function whateverYouWant(argument)
if argument == "hi" then
print("Hello!")
end
end
Why is it not good? It's because that code will take more memory for the server to run it. If you are making a large game, it'll causes lag.
The second one is commonly used because you don't have to open a new line for your listener. (Still unrecommended)
game.Workspace.Dummy.Humanoid.Died:Connect(function(argument)
warn("Oh no! Dummy down! D:")
end)
This one has the same issue that the upper one has.
The third one is the best.
local function whateverYouWant(argument)
if argument == "hi" then
print("Hello!")
end
end
If you only use the function code without listeners, they will never run.
Functions are like variables, you can store them into a variable. (Or remote function/remote event inside a script)
local function checkPassword(pass)
if pass == "password" then
return true
end
end
local passed = checkPassword(password)
if passed == true then
print("yay!")
end
I hope these helped you! For more information about functions/listeners, I recommend you to go on Roblox's API reference website or just learn it yourself! Good luck developing!
2 comments
Thanks!
The Died event passes no parameters, do not give OP code that will error.