game.Players.PlayerAdded:Connect(function(kills)
if kills.Parent.Humanoid.leaderstats.Kills == 1 then
print("hi")
end
end)
when you get 1 kill it dosent print the code in the output?
2 answers
If you are using a number value then you have to reference the value.
game.Players.PlayerAdded:Connect(function(kills)
if kills.Parent.Humanoid.leaderstats.Kills.Value == 1 then -- If you are using number value then "Kills" will have a value property
print("hi")
end
end)
The PlayerAdded event has a parameter known as the player that was added to the Players service.
You can look at the API of the player here.
I can't really help you because I don't know your hierarchy, for example, the location of your leaderstats. I got confused because the leaderstats has to always be in PlayerObject to be visible and not the humanoid of a Character.
For now, I'm just gonna locate the leaderstats based on your code.
SCRIPT
game.Players.PlayerAdded:Connect(function(player)
local Kills = player.Character.Humanoid.leaderstats.Kills
Kills:GetPropertyChangedSignal:Connect(function()
if Kills.Value == 1 then
print("hi")
end
end)
end)
Make sure it's a Script and not a LocalScript. If it was a LocalScript, it can be exploited badly.
EXPLANATION
Line 1 Connecting a function to a PlayerAdded event.
Line 2 Created a variable for the Kills IntValue.
Line 3 Connecting a function to the GetPropertyChangedSignal event.
Line 4 An if statement to check if the player has 1 kill.
Line 5 Printing "Hi".
You should put more effort into your question and make it more descriptive. To make a good question, you can check here.
This discussion is preserved as it was. New answers, comments, and votes are closed.
