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

I am trying to make a camera position changing GUI button but its not working any help?

Asked by 4 years ago
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local part = game.Workspace.Part
player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Fixed
camera.FieldOfView = 60
local runService = game:GetService('RunService')
local Stepped;
Stepped = runService.Stepped:Connect(function()
 camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,0,40)
end)

game.StarterGui.FullView.TextButton.MouseButton1Click:Connect(function()
    print("You clicked the button")
Stepped:Disconnect()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part.CFrame
end)

I have also tried to make a separate local script and it works but for few second I assume its due to stepped function changing camera back to default so I have no idea how I change the camera using local scripts any help would be greatly appreciated.

And I have also tried using playergui instead of starter GUI but If I use player GUI I don't know how to connect a function as player GUI is not pre-loaded in Roblox studio once again I would be really grateful if someone helps me out through this mess.

Answer this question