[UNSOLVED] Making A "Customization" Room

Hello, I am working on a roleplay game and I have stumbled across a problem. I am making it so when a player joins, it clones a room in replicated storage, places it at a random point, and teleports the player to it. However, it is not working. You don’t get teleported, or anything. There is also another problem, there is no way for me to change the cameras cframe on the server to the room’s clone camera part. How can I accomplish these two problems? Here is the script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local room = game:GetService("ReplicatedStorage"):WaitForChild("room"):Clone()
		room.Name = "{"..player.Name.."}".." 's room. . ."

		room:PivotTo(CFrame.new(math.random(1000,1000000), math.random(1000,1000000), math.random(1000,1000000)))
		character.PrimaryPart.CFrame = room.p.CFrame
		character.PrimaryPart.CFrame = character.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(270),0)
	end)
end)

Thanks!

Also forgot to mention the room in replicated storage as two parts, one being the part that the player teleports to, one being the camera part, and the other being the floor part.

is the script returning any errors? because I tested it (the teleport part) and it works

Nope. No errors, I just don’t get teleported to it. I added a print, and it prints, but doesn’t teleport me. I wonder why this is happening?

Did you use the script that I sent above or just the teleport part?

I guess I see the issue.

you didn’t parent the room’s clone to the workspace so it doesn’t have any parent aka not existing

I see. I am very stupid. Lemme try now.

Alright, so now it works, but I have a second problem. How can I make it so that the player’s camera cframe gets changed to the cframe of the room? I am asking this since I have looked around and it seems its pretty hard to change the cframe on the server.

Use a remote event that fires a localscript which changes the camera’s CFrame (done by workspace.CurrentCamera.CFrame = (yourCFrame), you can’t change the camera’s CFrame on the server.

I see, so how can I find the player’s room on the client to change the cameras cframe? I updated my script a bit:

local plrRooms = {}

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local room = game:GetService("ReplicatedStorage"):WaitForChild("room"):Clone()
		room.Parent = workspace.Rooms
		
		room.Name = "{"..player.Name.."}".." 's room. . ."
   
		room:PivotTo(CFrame.new(math.random(1000,1000000), math.random(1000,1000000), math.random(1000,1000000)))
		wait(0.1)
		character.PrimaryPart.CFrame = room.p.CFrame
        
		print('no')
		wait(1)
		plrRooms[player] = room
		game.ReplicatedStorage.Tpev:FireClient(player, room)
        print('yes')
		character.PrimaryPart.CFrame = character.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(270),0)
	end)
end)

How would I find the player’s room?

I see, so how I would I be able to find the player’s room on the client?

You can send the camera part’s CFrame to the client in this line:

game.ReplicatedStorage.Tpev:FireClient(player, room.YourCameraPartName.CFrame)

I see, so what would I put on the on client event function in the brackets? Since I can’t put

game.ReplicatedStorage.Tpev.OnClientEvent:Connect(function(player, room.c.CFrame)?

Since I tried this and it turns out as an error.

the local script brackets shouldn’t be the same as the server.

game.ReplicatedStorage.Tpev.OnClientEvent:Connect(function(roomlocation)
     -- you can reference the player using game.Players.LocalPlayer
     -- the room location reference the room's CFrame
end)```

Thanks, it now works! I appreciate you for sticking with me.

1 Like