What do you want to achieve? Keep it simple and clear!
I was making a round based system if one team won the match it will make the camera cframe to a parts cframe
What is the issue? Include screenshots / videos if possible!
I was using connections to disconnect/connect the RenderStepped function but once i try it at first time it actually disconnects but the second time it didnt work
THE CODE
local RS = game:GetService("ReplicatedStorage") local gameEvent = RS:WaitForChild("GameEvent") local camera = workspace.CurrentCamera local campart = workspace.CamPart local connection local renderconnection local Intermission = true connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function() if camera.CameraType ~= Enum.CameraType.Scriptable then camera.CameraType = Enum.CameraType.Scriptable end end) renderconnection = game:GetService("RunService").RenderStepped:Connect(function() camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = campart.CFrame end) gameEvent.OnClientEvent:Connect(function(intermission) if intermission == false then print(intermission) Intermission = intermission connection:Disconnect() renderconnection:Disconnect() elseif intermission == true then Intermission = intermission print(intermission) connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function() if camera.CameraType ~= Enum.CameraType.Scriptable then camera.CameraType = Enum.CameraType.Scriptable end end) renderconnection = game:GetService("RunService").RenderStepped:Connect(function() camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = campart.CFrame end) print(connection, renderconnection) end end)
-- Script inside the Part local part = script.Parent -- Function to handle the click event local function onClicked() print("Part clicked!") part.BrickColor = BrickColor.random() -- Change to a random color end -- Variable to store the connection local clickConnection -- Function to connect the click event local function connectClickEvent() if clickConnection then clickConnection:Disconnect() -- Disconnect the existing connection if any end clickConnection = part.ClickDetector.MouseClick:Connect(onClicked) print("Event connected") end -- Ensure the part has a ClickDetector if not part:FindFirstChild("ClickDetector") then local clickDetector = Instance.new("ClickDetector") clickDetector.Parent = part end -- Connect the click event initially connectClickEvent() -- Example of reconnecting the event (for demonstration purposes) -- In practice, you would call `connectClickEvent` wherever you need to ensure the event is reconnected wait(5) connectClickEvent()