local Player = script.Parent.Parent.Parent.Parent.Parent.Parent script.Parent.Text = tostring(script.Parent.ItemName.Value)..": "..tonumber(script.Parent.Cost.Value).." "..tostring(script.Parent.Currency.Value) script.Parent.MouseButton1Click:connect(function() local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(Player.Name) -- STOPS HERE if cashmoney ~= nil then if cashmoney.Value >= script.Parent.Cost.Value then cashmoney.Value = cashmoney.Value - script.Parent.Cost.Value game.Lighting.Shop.Swords[script.Parent.ItemName.Value]:Clone().Parent = Player.Backpack game.Lighting.Shop.Swords[script.Parent.ItemName.Value]:Clone().Parent = Player.StarterGear end end end)
The script is a "purchase" script inside of a Surface GUI on a brick. I have tried printing a number every single line, the script appears to stop just before if cashmoney ~= nil then, although cashmoney is present.
Try doing this:
local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(Player.Name)
It could be because cashmoney
is returning nil, due to the fact that the script couldn't locate it fast enough.
It's actually impossible for your script to stop where you specified - I think what actually happens is that cashmoney ~= nil
is false, and so nothing else runs. This can easily happen if there is no child named the same as Player.Name
in MoneyStorage
. To check this, print out the relevant values on line 6:
print("Cashmoney:", cashmoney) --if it just prints out "Cashmoney:", that means it's nil print(Player.Name) print(game.ServerStorage.MoneyStorage:FindFirstChild(Player.Name))