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

Change camera when gui button pressed?

Im using that script,its a local inside the button (GUI button) Something is wrong,it isnt working.

function onButton1Down()
game.Players.LocalPlayer.Character.Torso.CFrame=CFrame.new(Vector3.new(0,150,0))-- Teleport
wait()
	local Ncam=Workspace.Camera
	Ncam.CameraSubject=game.Players.LocalPlayer.Character.Humanoid
	Ncam.CameraType="Custom"
wait(0.2)
script.Parent.Parent.Parent.Parent.Parent.Backpack.CamFix:remove()
script.Parent.Parent.Parent:remove()
end

script.Parent.MouseButton1Down:connect(onButton1Down)

2 comments

0

local Ncam=workspace.CurrentCamera

0

connect, remove are deprecated, use Connect and Destroy. Also, use Enum.CameraType.Custom, not "Custom". Use more variables as well.

1 answer

Did you used a free model cause there is a bunch of deprecated things in this script..?

Fix:

-- Local Script
local Player = game:GetService("Players").LocalPlayer

function Clicked()
Player.Character:SetPrimaryPartCFrame(CFrame.new(0, 150, 0)) -- Teleports player

wait(.1)

local Camera = Player.CurrentCamera
    
Camera.CameraSubject = Player.Character.Humanoid

Camera.CameraType = Enum.CameraType.Custom

wait(0.2)
Player.Backpack:WaitForChild("CamFix"):Destroy() -- :remove() is deprecated 

script.Parent.Parent.Parent:Destroy()

end

script.Parent.MouseButton1Click:Connect(Clicked)

2 comments

0

I always use remove()..

0

Well dont do it, its deprecated ;)

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