What do you want to achieve? I am working in a plugin where the camera follows the player, like Camera Light, I want to make the part destroyed when the user stops editing the experience.
What is the issue? It will stay if you stop working on the experience
What solutions have you tried so far? There is nothing in the DevForums
here’s the code
local toolbar = plugin:CreateToolbar("CamLight")
local button = toolbar:CreateButton("CamLight", "", "rbxassetid://12942501521")
local active = false
local part, light
button.Click:Connect(function()
active = not active
part = Instance.new("Part")
light = Instance.new("PointLight", part)
if active then
part.Parent = workspace
part.Size = Vector3.new(0.001, 0.001, 0.001)
part.Parent = workspace
part.Name = "CamPart"
part.Locked = true
--// Light //--
light.Brightness = 1
light.Range = 60
light.Color = Color3.new(1, 1, 1)
light.Name = "CamLight"
light.Shadows = true
while active do
part:PivotTo(require(script:WaitForChild("Camera")).CFrame)
task.wait()
end
else
if workspace:WaitForChild("CamPart") then
workspace.CamPart:Destroy()
end
end
end)
I want to make a plugin like Camera Light (don’t worry I’m not publishing it to the marketplace), and I don’t know how to detect if the user stops editing the game.
local toolbar = plugin:CreateToolbar("CamLight")
local button = toolbar:CreateButton("CamLight", "", "rbxassetid://12942501521")
local active = false
local part, light
button.Click:Connect(function()
active = not active
part = Instance.new("Part")
light = Instance.new("PointLight", part)
if active then
part.Parent = workspace
part.Archivable = false
part.Size = Vector3.new(0.001, 0.001, 0.001)
part.Parent = workspace
part.Name = "CamPart"
part.Locked = true
--// Light //--
light.Brightness = 1
light.Range = 60
light.Color = Color3.new(1, 1, 1)
light.Name = "CamLight"
light.Shadows = true
while active do
part:PivotTo(require(script:WaitForChild("Camera")).CFrame)
task.wait()
end
else
if part then
part:Destroy()
end
end
end)
You might wanna check the “camera” module or whatever it is. Also you might wanna make sure the camera module actually exists.