This works perfectly in studio but does not work in-game. Only the XP part.
Here is the section of the script where I’ve added the XP.
OP
players = game.Players:getChildren()
local survivedt = {}
for i=1,#players do
local survived = getTag(players[i], "BoolValue", "survived", false)
if survived then
setTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Survivals", getTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Survivals", 0) + 1)
setTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Coins", getTag(players[i]:findFirstChild("leaderstats"), "IntValue", "Coins", 0) + 10)
setTag(players[i], "IntValue", "EXP", getTag(players[i], "IntValue", "EXP", 0) + 30)
table.insert(survivedt, players[i])
end
if not survived then
setTag(players[i], "IntValue", "EXP", getTag(players[i], "IntValue", "EXP", 0) + 15)
end
end
PlayerCompiler
function compilePlayers(players)
local names = ""
if #players == 1 then return players[1].Name end
for i=1,#players do
if i == #players then
names = names.. "and ".. players[i].Name
else
names = names.. players[i].Name.. ", "
end
end
return names
end
setTag
function setTag(parent, type, name, value)
local tag = parent:findFirstChild(name)
if tag ~= nil then
if tag.className == type then
tag.Value = value
else
local newTag = Instance.new(type)
newTag.Name = name
newTag.Value = value
newTag.Parent = parent
end
else
local newTag = Instance.new(type)
newTag.Name = name
newTag.Value = value
newTag.Parent = parent
end
end
getTag
function getTag(parent, type, name, default)
local tag = parent:findFirstChild(name)
if tag ~= nil then
if tag.className == type then
return tag.Value
else
print("No tag of the specified name and class was found in ", parent)
return default
end
else
print("No tag named ", name, " found in ", parent)
return default
end
end