Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

SurfaceGUI Button not Changing Players Camera Position?

I have a script which is supposed to change the players camera position when they click a button in a SurfaceGUI, how ever this does not work and I do not know why. Can you help?

LocalScript:

local player = game.Players.LocalPlayer
local character = player.Character
local camera = workspace.CurrentCamera

script.Parent.MouseButton1Click:Connect(function()
    local plr = game.Players.LocalPlayer
    local cam = workspace.CurrentCamera

    repeat wait()
        cam.CameraType = Enum.CameraType.Scriptable
    until cam.CameraType == Enum.CameraType.Scriptable
    cam.CFrame = script.Parent.Parent.Parent.Parent.CameraPart.CFrame
end)

3 comments

0

Use print() statement to determine where the script stops..

0

Uhmm, I think it should be 'game.Workspace' instead of just 'workspace'. I might be wrong, I haven't actually done it before

0

No, 'workspace' can work in the place of 'game.Workspace'. If anything, 'workspace' is better because it gets it regardless of workspace's name.

1 answer

Assuming campart is in workspace:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait();
local camera = workspace.CurrentCamera
local campart = workspace.CameraPart; -- change this to where your campart is

script.Parent.MouseButton1Click:Connect(function()
    cam.CameraType = Enum.CameraType.Scriptable
    cam.CFrame = campart.CFrame
end)

1 comment

0

many errors here it doesnt work like at all

This discussion is preserved as it was. New answers, comments, and votes are closed.