I have this FE script that goes nil when it is played. This is the error 20:42:48.509 - Players.powerdud.PlayerGui.LocalScript:2: attempt to index local 'XP' (a nil value)
I don't understand why this doesn't work. If someone could help me it would be much appreciated.This is my code
Server script
game.Players.PlayerAdded:connect(function()
local Data = Instance.new("IntValue")
Data.Parent = script.Parent.Parent
Data.Name = "Data"
local XP = Instance.new("IntValue")
XP.Parent = script.Parent.Parent
XP.Name = "XP"
XP.Value = 0
local Level = Instance.new("IntValue")
Level.Parent = script.Parent.Parent
Level.Name = "Level"
Level.Value = 1
local Tries = Instance.new("IntValue")
Tries.Parent = script.Parent.Parent
Tries.Value = 10
Tries.Name = "Tries"
local ExCap = Instance.new("IntValue")
ExCap.Parent = script.Parent.Parent
ExCap.Value = 500
ExCap.Name = "ExCap"
XP.Changed:connect(function() XP.Value,Level.Value,ExCap.Value) end)
end)
function XPChange(XP.Value,Level.Value,ExCap.Value)
game.Workspace.RemoteEvent:FireClient(ExCap,Level,XP)
end
Basically XP is changed it will fire a Event called FireClient
Local script
game.Workspace.RemoteEvent.OnClientEvent:Connect(function(ExCap.Value,Level.Value,XP.Values)
if XP.Value >= ExCap.Value then
if Level.Value < 100 then
Level.Value = Level.Value + 1;
XP.Value = XP.Value-ExCap.Value;
ExCap.Value = ExCap.Value * 2;
end
end
if Level.Value == 100 and XP.Value ~= 0 then
XP.Value = 0;
end
end)
When XP rises more than ExCap, XP will subtract from ExCap

4 comments
Can you show me how this would look like?
no sorry I can't rewrite the code for you that's not what this ebsite is for, I told you where your problem is and how to fix now you just have to apply it properly
Ok thanks alot
I changed the script a little bit 6 ^^ but i'm still have some errors. This is the server script error Workspace.Script:21: '=' expected near ')' this one is the Local script error error Players.powerdud.PlayerGui.LocalScript:1: ')' expected near '.'