Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(FE) Camera not switching to the humanoid?

Asked by 6 years ago

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

Log in to vote
-1
Answered by
lukeb50 631 Moderation Voter
6 years ago

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.

0
Thank you, but where should I put the local script? And can I undisable it from the script that's in ServerScriptService? BennyBoiOriginal 293 — 6y
0
Anywhere a localscript can normally execute. Depends on if the server can access the location(so not PlayerGui) lukeb50 631 — 6y
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. CootKitty 311 — 6y
0
I meant that based on the fact he wants to disable it. lukeb50 631 — 6y
Ad

Answer this question