Information:
Attempt:
local qualityhigh = true function Click(mouse) if qualityhigh == true then script.Parent.Text = "Increase Graphics" game.Workspace.HighQuality:Destroy() qualityhigh = false end if qualityhigh == false then script.Parent.Text = "Decrease Graphics" local copy = game.Lighting.HighQuality:Clone() copy.Parent = game.Workspace qualityhigh = true end end script.Parent.MouseButton1Down:connect(Click)
Edit: I fixed it by changing the parent and using elseif:
Answer:
local qualityhigh = true function Click(mouse) if qualityhigh == true then script.Parent.Text = "Increase Graphics" game.Workspace.HighQuality.Parent = game.Lighting qualityhigh = false elseif qualityhigh == false then script.Parent.Text = "Decrease Graphics" game.Lighting.HighQuality.Parent = game.Workspace qualityhigh = true end end script.Parent.MouseButton1Down:connect(Click)
Right, there is nothing much wrong with your script. If you want to destroy the clone, you're gonna need to name it. Naming your parts and using Instance:FindFirstChild()
will be the key to destroying and cloning parts. Also, if you're using a function for only purpose, you might as well use an anonymous function to save yourself from naming things.
local qualityhigh = false --You should for the lower PC counterparts first. script.Parent.MouseButton1Down:Connect(function() --Capitalise the connect, as it is deprecated. Also, if you're not using the parameter, don't use it. if not qualityhigh then --Same thing as if qualityhigh == false script.Parent.Text = "Decrease Graphics" local copy = game.Lighting.HighQuality:Clone() copy.Name = "LightPart" --You can name this whatever. copy.Parent = workspace --workspace and game.Workspace are the same thing. qualityhigh = true elseif qualityhigh then --Learning else and elseifs is the difference between level 1 and level 10 scripters. script.Parent.Text = "Increase Graphics" local copiedPart = workspace:FindFirstChild("LightPart") if copiedPart then --If the part exists (if not it returns nil) workspace.LightPart:Destroy() qualityhigh = false end end end)