Basically this is a Gui and it creates a frame it moves etc now when it gets to a certain position i want the frame to be removed now this works
-- Start of script while true do if script.Parent.Position.X.Offset ~= 260 then wait(.1) else if script.Parent.Position.X.Offset == 260 then
script.Disabled = true script:Destroy() script.Parent:Destroy() end end end
-- End of script
BUT It spams that Parent(script.Parent:Destroy()) is a Nil value in the output which tends to cause stress in game is their an easier way to delete them without this error?
I do not know why you are getting this error but its best if you stop the processing.
You can use 'break' to exit a loop safely and resume the next code block.
while wait(0.1) do -- wait is no in the while loop so we dont need to check it this will be read as true if script.Parent.Position.X.Offset == 260 then -- this may be a problem if you do not has Offser 260 you may want to use >= ? script.Parent:Destroy() -- destroy the parent break -- exit this loop so the rest of the code can run end end script:Destroy() -- if you wanted to remove the script but it is inactive
Hope this helps, pls comment if you do no understand this code.
``function del()
local Frames = script.Parent:GetChildren() for i=1, #Frames do if Frames[i].Name == "Square" then if Frames[i].Position.X.Offset == 260 then Frames[i]:Destroy() else if Frames[i].Name == "Square" then if Frames[i].Position.X.Offset ~= 260 then wait(0.1) end end end end end end while true do wait() thing() del() end
This is what i ended up doing don't mind thing(_) its another function above this part in the script