I looked through everything. What's wrong with it?
script.Parent.Touched:connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent.Money.Value >= 200 and hit.Parent.Name == script.Parent.Parent.Parent.Owner.Value then ----------------------------- hit.Parent.Money.Value = hit.Parent.Money.Value -200 ----------------------------- script.Parent.Parent.Parent.WallUpgrade2.Wall1.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall1.CanCollide = false script.Parent.Parent.Parent.WallUpgrade2.Wall2.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall2.CanCollide = false script.Parent.Parent.Parent.WallUpgrade2.Wall3.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall3.CanCollide = false script.Parent.Parent.Parent.WallUpgrade2.Wall4.Transparency = 0 script.Parent.Parent.Parent.WallUpgrade2.Wall4.CanCollide = false ----------------------------- script.Parent.Transparency = 1 script.Parent.CanCollide = false script.Parent.Parent.BuyWallsLabel.SurfaceGui.TextLabel.TextTransparency = 1 script.Disabled = true ----------------------------- end end)
Thanks in advance for your help!
==EDIT== Okay, so when I checked the Output it said that the error was somewhere in line 2:
if game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent.Money.Value >= 200 and hit.Parent.Name == script.Parent.Parent.Parent.Owner.Value then
Well you checked for the player then decided to access the character to change the money silly(:
Also, you can use a for loop to manipulate the walls for efficiency.
local owner = script.Parent.Parent.Parent.Owner local db = false script.Parent.Touched:connect(function(hit) if db == false then db = true local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr and plr.Money.Value >= 200 and plr.Name == owner.Value then ----------------------------- plr.Money.Value = hit.Parent.Money.Value - 200 ----------------------------- local walls = script.Parent.Parent.Parent.WallUpgrade2 ----------------------------- for i = 1,4 do local wall = walls:FindFirstChild("Wall"..tostring(i)) wall.Transparency = 0 wall.CanCollide = false --You might want this to be true:P end ----------------------------- local TextLabel = script.Parent.Parent.BuyWallsLabel.SurfaceGui.TextLabel script.Parent.Transparency = 1 script.Parent.CanCollide = false TextLabel.TextTransparency = 1 script.Disabled = true ----------------------------- end db = false end end)