I have made a simple script to remove something from the game when i touch a block but when i touch the block it tells me LaserGate1 is not a valid member of Workspace even though LaserGate1 is under workspace
function onTouched(hit) game.Workspace.LaserGate1 = nil end script.Parent.Touched:connect(onTouched)
Hello. Your method in doing this isnt exactly corrent. What your probably trying to do is remove, or destroy LaserGate1. To accomplish this, do the following:
function onTouched(hit) game.Workspace.LaserGate1:Destroy() end script.Parent.Touched:Connect(onTouched)
You will see that I have replaced line 2. You were on the right track in trying to set the object to nil because what destroy does, is set the objects PARENT to nil, you were just missing the .Parent. Besides that point, :Destoy() was implemented specifically for this, thus its what I suggest you use. I hope I was able to help! ~mc3334