Am I doing something wrong here? I want this counter to go up by one each time the “enemykilled” RemoteEvent is fired. It’s as if it only fires once, though, the counter only remaining at 1 no matter how many times I fire it afterwards.
local rs = game:GetService("ReplicatedStorage")
local enemykilled = rs:WaitForChild("enemykilled")
local soulcounter = 0
local soulslabel = script.Parent
enemykilled.OnClientEvent:Connect(function(player)
soulslabel.Text = "souls: ".. soulcounter + 1
end)
its because youre not increasing the soulcounter variable so the script will always try to do 0 + 1
local rs = game:GetService("ReplicatedStorage")
local enemykilled = rs:WaitForChild("enemykilled")
local soulcounter = 0
local soulslabel = script.Parent
enemykilled.OnClientEvent:Connect(function(player)
soulcounter += 1 --// add 1 to the variable
soulslabel.Text = "souls: ".. soulcounter --// no need for the +1 since we already added
end)