Hello.
This is my code for a camera script in StarterPlayerScripts
local targets = {PTN = workspace.PizzatownNorthCameraPoint,MDL=workspace.MaldonCameraPoint}
--local gstate = script.Parent.gstate
local camera = workspace.CurrentCamera
local angle = 0
local i = 1
local gstate = script.gstate
local vpoint = script.point
game.ReplicatedStorage.Camera.OnClientEvent:Connect(function(place,state,point)
if place == "scripts" then
gstate.Value = state
vpoint.Value = point
print("Got event")
print("Place:",place,"state",gstate.Value,"Target:",vpoint.Value)
while i == 1 do
--print("INO")
target = targets[script.point.Value]
if gstate.Value == "On" then
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
end
target = targets[script.point.Value]
camera.CameraSubject = target
--print("In2")
-- print(target)
camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part
* CFrame.Angles(0, angle, 0) --Rotate by the angle
* CFrame.new(0, 0, 1) --Move the camera backwards 1 unit(s)
angle = angle + math.rad(1)
end
script.point.Changed:Connect(function()
target = targets[script.point.Value]
-- print("Changed")
camera.CameraType = Enum.CameraType.Custom
wait(0.2)
camera.CameraType = Enum.CameraType.Scriptable
end)
wait(0.05)
end
end
end)
The issue is when a new button is clicked, the spinning gets faster.
Here is the link to the game: Pizza Railways - Roblox
Spawn as a passenger to test it.
Thanks in advance,
Sasial.