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

(FE) Camera not switching to the humanoid?

I have a script that handles the remote events that are in Replicated Storage and the script is in ServerScriptService. I hit a button on a gui and it disables a local script that is in PlayerGui and is supposed to change the camera type to custom and the camera subject to the player's humanoid, however, it just keeps the options that are set in the local script. When a run a test server, the server sees the local script in the player gui, but the client doesn't.

Script in ServerScriptService:

local TeamChangeEvents = game:GetService('ReplicatedStorage'):WaitForChild('TeamChangeEvents')
local TeamEastChangeClick = TeamChangeEvents:WaitForChild('TeamEastChangeClick')
local TeamWestChangeClick = TeamChangeEvents:WaitForChild('TeamWestChangeClick')

TeamEastChangeClick.OnServerEvent:connect(function(plr, button)
	
	plr.TeamColor = BrickColor.new("Really blue")
	
	button.Parent:TweenPosition(UDim2.new(-1.5,0,0,85), 'Out', 'Linear')
	button.Parent.Parent.WestTeam:TweenPosition(UDim2.new(1.5,0,0,-85), 'Out', 'Linear')
	
	if (plr.Character.Humanoid.RigType == Enum.HumanoidRigType.R15) then
		plr.Character.UpperTorso:Destroy()
	else 
		plr.Character.Torso:Destroy()
	end
	print("KILLED east")
	wait(5.5)
	workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	plr.PlayerGui:WaitForChild('SmartLock').Disabled = true
	
	plr.Character.Humanoid.WalkSpeed = 16
	plr.Character.Humanoid.JumpPower = 50
	plr.Character:MoveTo(workspace.EastSpawn.Position)	
	
end)

TeamWestChangeClick.OnServerEvent:connect(function(plr, button)

	plr.TeamColor = BrickColor.new("Really red")
	
	button.Parent:TweenPosition(UDim2.new(1.5,0,0,-85), 'Out', 'Linear')
	button.Parent.Parent.EastTeam:TweenPosition(UDim2.new(-1.5,0,0,85), 'Out', 'Linear')
	
	if (plr.Character.Humanoid.RigType == Enum.HumanoidRigType.R15) then
		plr.Character.UpperTorso:Destroy()
	else
		plr.Character.Torso:Destroy()
	end
	print("KILLED east")
	wait(5.5)
	plr.PlayerGui:WaitForChild('SmartLock').Disabled = true
	workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	
	plr.Character.Humanoid.WalkSpeed = 16
	plr.Character.Humanoid.JumpPower = 50
	plr.Character:MoveTo(workspace.WestSpawn.Position)
	
end)

1 answer

The Camera, just like anything in PlayerGui(with FE on) is Local, so the server cannot access/change them. Use a localscript to perform camera changes.

4 comments

0

Thank you, but where should I put the local script? And can I undisable it from the script that's in ServerScriptService?

0

Anywhere a localscript can normally execute. Depends on if the server can access the location(so not PlayerGui)

0

Local Scripts work in PlayerGui. Local Scripts also work in the character, for example. Just because the server can access a location doesn't mean local scripts can't run there.

0

I meant that based on the fact he wants to disable it.

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