Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CameraType not changing when button clicked?

Asked by 7 years ago

i made a script that when you press the TextButton it changes the camera type. Here is the script

sorry the title sounds weird nothing would work D:

local clicked = 1

script.Parent.MouseButton1Click:connect(function(a)
    clicked = clicked + 1
    print(clicked)
end)

local a = game.Players.LocalPlayer

if clicked == 1 then
    local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Custom

end
if clicked == 2 then
    local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Attach
end

What is wrong with the script?

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

The problem is, the if statements will only run once. What u need to do is, put both if statements in the MouseButton1Click'ed function.

0
Also, set Clicked = 0 FiredDusk 1466 — 7y
Ad

Answer this question