Localscript Unable to :Destroy() object

CODE:

script.Parent.MouseButton1Click:connect(function()
  if script.Parent.Text == "Enabled" then
	print("Disabling Motion Blur")
	script.Parent.Text = "Disabled"
	 script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.MotionBlur:Destroy()
elseif script.Parent.Text == "Disabled"
	then
	print("Enabling Motion Blur")
		script.Parent.Text = "Enabled"
	 script.MotionBlur:Clone().Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
end
end)

When I click the button, it prints but the Motion Blur script isn’t destroyed for some reason, thanks

1 Like

Is the game in experimental mode?

Is the object it destroying somewhere like Workspace or Lighting where client doesn’t have effective access to with filtering enabled?

Its filtering enabled, the object is in startergui and so is the textbutton, so it has access to destroy it. But it’s not cloning or destroying for some reason

StarterGui cannot be accessed by a client in that case. Do you mean PlayerGui inside the player?

yes image

Any errors?

Also it might be better to save it to a variable so you don’t need to risk anything:

local MotionBlur = script:WaitForChild("MotionBlur")
local CurrentMotionBlur

script.Parent.MouseButton1Click:Connect(function()
    if CurrentMotionBlur then
        CurrentMotionBlur:Destroy()
    else
        CurrentMotionBlur = MotionBlur:Clone()
        CurrentMotionBlur.Parent = script.Parent.Parent... -- continue on
    end
end)
1 Like

no errors

Try my code and see how it works then :wink:

nope, still not working

Are you sure it’s setup right? This seems a bit odd.

Yes

ill try making another test script

i tried using this

local CurrentMotionBlur = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.MotionBlur
	 CurrentMotionBlur:Destroy()

and its not destroying as well

Is the script enabled?

Yes

It even prints “Motion blur disabling/enabling” its just not destroying/cloning

Wow this makes no sense

Would I be able to join the TC?

I don’t think so… but i can give you the file

Whatever works

Add me on discord if you like, and we can go over this

EmeraldSlash#9138

Found an error

14:05:39.300 - The Parent property of MotionBlur is locked, current parent: NULL, new parent Workspace