This script was brought up in another question, but it was a while a go and was not given a working answer. Please go over my script and help me figure out what is wrong with it.
local owner = script.Parent.Parent.Parent.Owner local db = false script.Parent.Touched:connect(function(hit) if db == false then db = true if hit.Parent.leaderstats.Money.Value >= 200 and hit.Parent.Name == owner.Value then ----------------------------- hit.Parent.leaderstats.Money.Value = hit.Parent.leaderstats.Money.Value - 200 ----------------------------- script.Parent.Parent.Parent.WallUpgrade2.Wall1.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall1.CanCollide = true script.Parent.Parent.Parent.WallUpgrade2.Wall2.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall2.CanCollide = true script.Parent.Parent.Parent.WallUpgrade2.Wall3.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall3.CanCollide = true script.Parent.Parent.Parent.WallUpgrade2.Wall4.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall4.CanCollide = true ----------------------------- script.Parent.Transparency = 1 script.Parent.CanCollide = false script.Parent.Parent.BuyWallsLabel.SurfaceGui.TextLabel.TextTransparency = 1 script.Disabled = true ----------------------------- end db = false end end)
Thank you in advance for your help.
BTW: There is an error in line 7. ;)
You will have to find the player's character:
(put this inside the Touched function)
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- This method searches Players for a player that has the character model we input. if player then -- Make sure it exists before we continue. If it doesn't exist, it could break the game. local stat = player:findFirstChild("leaderstats"):findFirstChild("Money") if stat then -- code. end end