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

Spectate Gui, No i'm not asking for it, just help me fix mine?

So I have a ScreenGui (in StarterGui of course) And it has 2 textbuttons. One called spec and one called Nextt. The first one is just the spectate button, the Nextt one is to switch players. Here's the spec script: (local)

local on = false
local Players = game.Players:GetChildren()
local PlayerSubject = Players[math.random(1, #Players)]
local Camera = game.Workspace.CurrentCamera 

script.Parent.MouseButton1Down:connect(function()
	if on == false then
		Camera.CameraType = "Follow"
		Camera.CameraSubject = PlayerSubject.Character.Humanoid
		script.Parent.Parent.Nextt.Visible = true
		script.Parent.Text = "Close"
		on = true
	end
	
	if on == true then
		script.Parent.Parent.Nextt.Visible = false
		script.Parent.Text = "Spectate"
		on = false
	end
end)

And here's the nexxt button's script:

script.Parent.MouseButton1Down:connect(function()
	local Players = game.Players:GetChildren()
	local PlayerSubject = Players[math.random(1, #Players)]
	local Camera = game.Workspace.CurrentCamera 
	Camera.CameraType = "Follow"
	Camera.CameraSubject = PlayerSubject.Character.Humanoid
end)

It doesn't work though, I started a server, and two players, and completely no output, whatsoever. Will this only work in-game or what?

1 comment

0

Both scripts are local*

1 answer

I think the problem is is that when the CameraSubject is a Humanoid, you can only use the 'Custom' CameraType. Try that then post back :)

2 comments

0

That worked fine, but in my game the players lock first person during the round, so when I spectate another player, how can I make it so they can zoom in and out because you can't close spectate like that.

0

Sorry, I don't know if that's possible.

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