When you click Script A below, it clones the model, and Script B works fine, but if you click Script A again to destroy it, and click it again to clone it again Script B doesn't work anymore..!
SCRIPT A :
local dir2 = game.ReplicatedStorage.Bot_2 isOn = false function click() isOn = true local s = dir2:Clone() s.Parent = game.Workspace end function off() isOn = false local d = game.Workspace:WaitForChild("Bot_2") d:Destroy() end function main() if isOn == false then click() else off() end end script.Parent.ClickDetector.MouseClick:connect(main)
SCRIPT B :
local dir = game.Workspace:WaitForChild("Bot_2") function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.F then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Really red") dir.Head.PointLight.Color = BrickColor.new("Really red").Color end end end if inputObject.KeyCode == Enum.KeyCode.G then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Really blue") dir.Head.PointLight.Color = BrickColor.new("Really blue").Color end end end if inputObject.KeyCode == Enum.KeyCode.H then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Lime green") dir.Head.PointLight.Color = BrickColor.new("Lime green").Color end end end if inputObject.KeyCode == Enum.KeyCode.J then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("New Yeller") dir.Head.PointLight.Color = BrickColor.new("New Yeller").Color end end end if inputObject.KeyCode == Enum.KeyCode.K then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Royal purple") dir.Head.PointLight.Color = BrickColor.new("Royal purple").Color end end end if inputObject.KeyCode == Enum.KeyCode.L then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Deep orange") dir.Head.PointLight.Color = BrickColor.new("Deep orange").Color end end end if inputObject.KeyCode == Enum.KeyCode.Semicolon then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Hot pink") dir.Head.PointLight.Color = BrickColor.new("Hot pink").Color end end end if inputObject.KeyCode == Enum.KeyCode.C then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("White") dir.Head.PointLight.Color = BrickColor.new("White").Color end end end if inputObject.KeyCode == Enum.KeyCode.P then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then v.BrickColor = BrickColor.new ("Really black") dir.Head.PointLight.Color = BrickColor.new("Really black").Color end end end if inputObject.KeyCode == Enum.KeyCode.V then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then dir.Tilt.C02.ParticleEmitter.Enabled = true end end end if inputObject.KeyCode == Enum.KeyCode.B then for i,v in pairs(dir:GetChildren()) do if v.Name == "Neon" then dir.Tilt.C02.ParticleEmitter.Enabled = false end end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)