I’m creating a training center for my roblox group and I just couldn’t figure out how to script a view host gui sort of thing.
Basically when a user says “viewhost” it makes all users screens go to the hosts. I’m struggling on finding the right tutorials to complete this. If you have any ideas of how to do this please reply.
First you want to fire a remote from the server to the client like this
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "viewhost" then
game.ReplicatedStorage.RemoteEvent:FireAllClients()
end
end)
end)
Then you want to modify the players camera on the client like this.
local HostTeam = game.Teams.Host:GetPlayers()
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
for _, otherPlayer in pairs(HostTeam) do
Camera.CameraSubject = otherPlayer.Character
break
end
end)