Very strange problem, can someone help?
I am working on a game which has FilteringEnabled active, when a player joins a local script is cloned to their character in workspace which fixes the camera in place and activates a remote event causing a script in workspace to move the character to another room.
The scripts work fine in test mode however when published or when I start the server the character is not teleported on the clients screen but on the server the player is in the correct place as shown in the screenshot below:
https://gyazo.com/e50a7f62f03c2247a8f15f97f0213d25
The code on the server script in workspace is:
01 | game.Players.PlayerAdded:connect( function ( player ) |
03 | print (player.Name .. tostring ( " has joined" )) |
05 | repeat wait() until player.Character.Torso |
07 | local character = player.Character |
10 | script.CameraScript:clone().Parent = character |
20 | function event.OnServerInvoke(player, reply) |
22 | repeat wait() until player.Character.Torso |
24 | if player.Character and player.Character:FindFirstChild( "Torso" ) then |
26 | local character = player.Character |
28 | print ( "Moving character" ) |
29 | character.Torso.CFrame = CFrame.new(- 193.6 , 4.5 , 0 ) |
30 | character.Torso.Anchored = true |
32 | print ( "Character moved" ) |
34 | if character.ForceField then |
35 | character.ForceField:Destroy() |
The code on the client is:
01 | local cam = workspace.CurrentCamera |
02 | local Torso = script.Parent.Torso |
04 | print ( "Fireing server" ) |
06 | local wiatForResponse = game.Workspace.Teleport.ClReady:InvokeServer(reply) |
08 | cam.CameraSubject = Torso |
09 | cam.Focus = CFrame.new(Torso.Position) |
10 | cam.CameraType = "Scriptable" |
11 | cam.CoordinateFrame = CFrame.new(Torso.Position - Vector 3. new( 3 , - 3 , 10 ), Torso.Position + Vector 3. new(- 4 , 0 , 0 )) |