inside a p:art called "Spirit" there are two scripts:
one Supposedly should give EXP when touched by the "WaterEssence":
P.D.: "EXP" is in a folder named "leaderstats" inside the character
local ATM = script.Parent ATM.Touched:connect(function(entity) print(entity:GetFullName()) if entity.Parent.Name == "WaterEssence" then local Man = entity.Parent.Parent.Parent local RealMan = game.Players:GetPlayerFromCharacter(Man) local Bro = RealMan.FindFirstChild("leaderstats") local EXP = RealMan.Bro:FindFirstChild("EXP") EXP.Value = EXP.Value + 100 print(EXP.Value) wait(1) end end)
the other one just makes it invisible.
script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == "WaterEssence" then script.Parent.Transparency = 0.5 wait(20) script.Parent.Transparency = 0 end end)
the invisible script works fine, but the other one shows this error:
error: Workspace.Spirit.Script:12: attempt to index local 'RealMan' (a nil value)
if you dont have any ideas, please give me an alternative way to do it.
Thanks to everyone, SuVee, Aspiring Dev
local ATM = script.Parent ATM.Touched:connect(function(entity) print(entity:GetFullName()) if entity.Parent.Name == "WaterEssence" and game.Players:FindFirstChild(entity.Parent.Parent.Name) then -- local Man = entity.Parent.Parent.Parent local RealMan = game.Players:FindFirstChild(entity.Parent.Parent.Name) local Bro = RealMan:FindFirstChild("leaderstats") local EXP = Bro:FindFirstChild("EXP") EXP.Value = EXP.Value + 100 print(EXP.Value) wait(1) end end)