Server can "see" all parts and client can "see" some parts

  1. What do you want to achieve? I am attempting to make the player’s camera a certain part in the workspace.

  2. What is the issue? When I try to do this through a local script, the local script returns a wait for child error, or says that the part does not exist.

  3. What solutions have you tried so far? I’ve looked around for answers but most didn’t seem well enough to help me. I’ve also tried making the part singular (rather than in a model) but still no luck.

The error:

Server side: Screen Shot 2020-12-12 at 10.49.38 PM

Client Side: Screen Shot 2020-12-12 at 10.49.15 PM

As you can see here, the part is in the workspace, it just seems that the client cant references it?

I would make a remote function, going from client to server and then back to the client, but this seems extremely unnecessary as I’ve done this before.

2 Likes

Check and see if the client is removing the contents of the boxes somehow, also send the script so we can see what you are trying to do

1 Like

Can you publish your code please ?

1 Like

sure!

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("PlayerJoined")

-- Ignore the passed player; start with additional passed data
local function onfreezeplayer(picked_value)
	print("Picked value:")
	print(picked_value)
	print("Incoming server event...")
	local lplayer = game.Players.LocalPlayer
	print(lplayer)
	repeat wait() until lplayer.Character
	local char = lplayer.Character
	local head = char:WaitForChild('Head')
	char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(picked_value))
	print("e")
	head.Anchored = true
	print("Your head should be anchored")
	local humanoid = char.Humanoid
	humanoid.WalkSpeed = 0
	
--change cam
	local Players = game:GetService("Players")
	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = game.Workspace.SpawnBoxes.SB1cam

	-- Fire the remote event
	remoteEvent:FireServer()



	

	
end

-- Call "onNotifyPlayer()" when the server fires the remote event
remoteEvent.OnClientEvent:Connect(onfreezeplayer)


ignore the random remote event fire

So it actually exists, due to a visual bug in ROBLOX studio it doesn’t show, but if you right click and click on an option that says
image

It will then show up on the client, the problem with your script is that you are looking inside SpawnBox1 for SB1Cam instead of SpawnBoxes for SB1Cam
image

Ok so I’ve updated my script and included a wait for child and I still get an error saying there’s an infinite yield. I can see the part in the workspace (Literally this time) but the game thinks it’s not there?

Can you select workspace and tell me if “Streaming Enabled” is on?

It is on. Could that be the issue?

( I turned it on since my map is huge)

Yes, this is most likely the issue. The server will always have access to everything in workspace, but for the client it depends whether or not the part is streamed in. As mentioned in api you should use waitForChild (which you did) but this doesn’t mean the player will ever go near that part and/or actually stream it in.

What I would do is store your “Camera parts” in a folder inside ReplicatedStoarge. Then reference that part in replicatedStorage instead of referencing it in workspace. You will also have to use :RequestStreamAroundAsync() in order for the map to load in that area. Otherwise the camera will cframe but there will be nothing pretty to look at.

Note that I’m typing on mobile so there may be typos.

Hope this helps and goodluck!

1 Like

Thank you for the help! I was able to try this and the camera now goes to the correct position, but the player does not teleport. I’m not sure if this is related to the fix, but before the player would teleport.

Here’s the entire script


local remoteEvent = ReplicatedStorage:WaitForChild("PlayerJoined")

-- Ignore the passed player; start with additional passed data
local function onfreezeplayer(picked_value)
	local lplayer = game.Players.LocalPlayer
	print(lplayer)
	local spawnbox = CFrame.new(179.5, 16108.009, -3258.5)
	lplayer:RequestStreamAroundAsync(spawnbox.Position)
	print("Picked value:")
	print(picked_value)
	print("Incoming server event...")
	
	
--change cam
	local Players = game:GetService("Players")
	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable
	local WFC = game.ReplicatedStorage:WaitForChild("SB1cam")
	camera.CFrame = game.ReplicatedStorage.SB1cam.CFrame

--Anchor head and stop player from moving
	repeat wait() until lplayer.Character
	local char = lplayer.Character
	local head = char:WaitForChild('Head')
	char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(picked_value))
	print(picked_value)
	head.Anchored = true
	print("Your head should be anchored")
	local humanoid = char.Humanoid
	humanoid.WalkSpeed = 0

end

-- Call "onNotifyPlayer()" when the server fires the remote event
remoteEvent.OnClientEvent:Connect(onfreezeplayer)

The player just spawns at what i presume is the default spawning location.

  1. Are there any errors?
  2. Where exactly is the player spawning?
  3. What is picked_value (possibly print it)?
  1. No there weren’t pertaining to the script
  2. At what I believe is the wor origin
  3. Picked value is a value picked from a table of CFrames, but the player dosent spawn at any
char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(picked_value))

Right after that can you print(char.HumanoidRootPart.CFrame) and print(CFrame.new(Vector3.new(picked_value))).

Could you also maybe provide a video, gif, or picture of whats happening?

Ok so I’ve made the video and actually, it seems that the values are 0 now.

Hope you’re okay with watching a YT video. The video kept erroring here.

Also since the video is a bit blurry the two prints come back as 0 for whatever reason.