I have leaderstats in the game but when I test in studio they are there and when I go to my game they are not, Could the reason be because the error message and how do I fix
COMMUNITY QUESTION
When I publish my game to roblox it says script will won't be published?
1 answer
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Lvl = Instance.new("NumberValue", leaderstats)
Lvl.Name = "Level"
Lvl.Value = 1
local EXP = Instance.new("NumberValue", leaderstats)
EXP.Name = "EXP"
local MaxEXP = Instance.new("IntValue", leaderstats)
MaxEXP.Name = "MaxExp"
MaxEXP.Value = 100 * (Lvl.Value / 2)
game.ServerStorage.GiveExp.Event:Connect(function(amount,plr)
if player.Name == plr.Name then
EXP.Value = EXP.Value + amount
end
end)
EXP:GetPropertyChangedSignal("Value"):Connect(function()
if EXP.Value >= MaxEXP.Value then
EXP.Value = EXP.Value - MaxEXP.Value
wait(0.01)
Lvl.Value = Lvl.Value + 1
MaxEXP.Value = 100 * (Lvl.Value)
end
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
What is the error message?