Please help me this is an very important script for me, it's just a simple thing which doesn't work. I made it work remove it and check for cash but the player doesn't have money at first time button stops working. So it's like player presses the button without having 5 cash in his value, it breaks and when he gets 5 cash the button won't ever work again, but if you have cash 5 in value and didn't press it before when u had 0 cash it will work... Why ? I made it check for money why doesn't it work ? Please guys help me i really need this and don't ignore it! thank you very much!
https://www.youtube.com/watch?v=tD9xztrc1tU ** heres a video for MORE INFO**
model = script.Parent.Parent.Parent.Door Upgradecost = 5 local ting = 0 function onTouched(hit) if ting == 0 then ting = 1 hit.Parent:FindFirstChild("Humanoid") local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player ~= nil then if script.Parent.Parent.Parent.Parent.Owner.Value == player then if hit.Parent:FindFirstChild("Humanoid") then local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name) if cashmoney ~= nil then if cashmoney.Value >= Upgradecost then cashmoney.Value = cashmoney.Value - Upgradecost model:remove() script.Parent.Parent:remove() ting = 0 end end end end end end end script.Parent.Touched:connect(onTouched)
Workspace.Script:2: attempt to index field 'Parent' (a nil value) <<<< bloody error ?
My guess is that i forgot to do is if the player doesn't have enough money stop the script, but how i do that ?
i've gave as much info as i can, thank you all for your time.