Hey everyone! I added something to my script, and it doesn’t work. There is nothing in the output saying that it doesn’t work. The part I added was where it gives someone a point whenever they get a kill.
Use the debugger to execute every line of code separately and check if the values of your variables match your expectations, then you can hopefully see where the script suddenly stops. Alternatively, you can add print statements to check whether certain lines of code get reached during execution.
This simply opens multiple clients that you can use to test. It’s very helpful if you don’t have a team of people to throw a game at. They will have the names Player1, Player2, ect. You also get separate windows for the server and client, so client-server replication is easier to test.
But I already know which part of my script isn’t working. It is the part that is supposed to give someone a point when they get a kill. The problem is fixing the bug.
You shouldn’t be making these connections if a player doesn’t exist, that’s likely part of your issue:
if player then
character = player.Character
if not character then
-- Left the game
table.remove(plrs,i)
else
if character:FindFirstChild("GameTag") then
-- They are still alive
print(player.Name.." is still in the game!")
else
-- They are dead
table.remove(plrs,i)
print(player.Name.." has been removed!")
end
end
else
table.remove(plrs,i)
print(player.Name.." has been removed!")
player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function(Died)
local creator = Character.Humanoid:FindFirstChild("creator")
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator ~= nil and creator.Value ~= nil then
leaderstats.Points.Value = leaderstats.Points.Value + 1
end
end)
end)
end
In the bit above, the died event is only connected if the player is removed, which will never happen. You should connect these events in the beginning, in an event like PlayerAdded.