Hello guys, i'm developing my first game and i'm with a trouble: I've created the Lvl up system in a LocalScript:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
if Player then
local leaderstats = Instance.new("IntValue", Player)
leaderstats.Name = "leaderstats"
local EXP = Instance.new("NumberValue", leaderstats)
EXP.Name = "EXP"
EXP.Value = 0
local Level = Instance.new("NumberValue", leaderstats)
Level.Name = "Level"
EXP.Changed:connect(function()
if EXP.Value >= Level.Value*100 then
EXP.Value = EXP.Value - Level.Value*100
Level.Value = Level.Value+1
end
end)
end
And for test I put a Part in the workspace, with this (normal)script:
d = true
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if d == true and humanoid ~= nil then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats = Player:WaitForChild("leaderstats")
local EXP = leaderstats.EXP
if d == true then
d = false
EXP.Value = EXP.Value+100
wait(1)
d = true
end
end
end)
But when I touch the part, it says "09:15:09.157 - leaderstats is not a valid member of Player" Why this is happening and how can i fix? I guess that's because i'm trying to change a Local value with a Normal script, but i need these values to be in the Local so i can change it with a Gui latter.

2 comments
localscripts only change things for the client iself; therefor it shouldn't be used to create values inside the player that the server needs to read/write to/from
But i want to acces and change these values with a Gui latter, I cant properly change with a LocalScript