I'm trying to write a script that when i get to a certain score, a wall will break. My score is stored as a _G and I'm using an if statement such as the one below to tell it when to break the wall but it's not working. I'm fairly new to scripting in Roblox so any help would be really appreciated.
local event = script.Parent
local pointlight = script.Parent.PointLight
_G.score = 0
local function onPartTouched(otherPart)
partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
pointlight:Destroy()
event:Destroy()
_G.score = _G.score + 1
print(_G.score)
end
end
event.Touched:Connect(onPartTouched)
This is what I have as the script storing the variable
local breakwall = game.Workspace.breakWall
local score = _G.score
if score == 1 then
breakwall:Destroy()
end
To give any information that might help, the script that is breaking the wall is located in ServerScriptStorage

1 comment
Sorry if this might be confusing to read