I want to create a script that when I click “Onoff” button it changes if its on or off and when I click play button that triggers the camera script go in the first person or not. How can i make it?
Here is my script from play button:
local Sound = script.Parent.Sound
local Plr = game.Players.LocalPlayer
local onoffButton = game.StarterGui.MenuGUI.Frame.Onoff -- Assuming the button has this path
local onoffState = false -- Variable to store the state of the "Onoff" button
local ui = script.Parent.Parent
local CurrentCamera = workspace.CurrentCamera
local Part = workspace:WaitForChild("MenuCamera")
local PlayBTN = script.Parent
wait(0.001)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = Part.CFrame
game.Workspace.MenuCamera.Transparency = 1
game.Workspace.MenuCamera.cutewaballcat.Transparency = 1
local function SetCameraMode()
if onoffButton.Text == "On" then
Plr.CameraMode = Enum.CameraMode.LockFirstPerson
else
Plr.CameraMode = Enum.CameraMode.Classic
end
end
script.Parent.MouseButton1Click:Connect(function(click)
Sound:Play()
ui:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Sine", 0.5)
SetCameraMode()
end)