Attempting to spawn a player in a structure underwater

  • I’m attempting to resolve a problem caused by roblox’s spawn.
  • I’m attempting to see if it’s possible to spawn inside the ring rather than be forced to spawn outside of the build.as It has enough space for the character to swim so I don’t understand why this isn’t achievable…
  • The only viable solution I’ve determined would be this however, I have 0 prior knowledge in programming so even a simple problem as this has halted me from expanding on to the build.

I’m aiming to create a more depth pipe structure so if anyone can offer a solution or voluntarily distribute script that’ll solve this problem than I would greatly appreciate it.

Ring test.rbxl (86.6 KB)

2 Likes

You can manually set the CFrame of the Character’s RootPart to the desired CFrame using Player.CharacterAdded.

Example:

 local Players = game:GetService("Players")
 
 Players.PlayerAdded:connect(function(Player)
     Player.CharacterAdded:connect(function(Character)
         Character:WaitForChild("HumanoidRootPart").CFrame = Workspace.Example.CFrame
     end)
 end)

^ Make sure this is a server-sided script.

I hope i helped :stuck_out_tongue:

6 Likes

Thank you I’ll test out your solution immediately. By server sided, would that imply it goes under one of the following categories (If so which one?) : Server Storage, Server Script Service, or am I misunderstanding what you meant by server sided?

Cframe = XYZ coordinates of the part correct? If so, than my modification to your code should work.

it has to be a Script, not a LocalScript, put it in ServerScriptService and everything should work fine

 local Players = game:GetService("Players")
 
 Players.PlayerAdded:connect(function(Player)
     Player.CharacterAdded:connect(function(Character)
         Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(X,Y,Z)
     end)
 end)
2 Likes
Current progress, what did I do wrong?


image

I know this was originally intended to be a building related question however would it be acceptable if I moved this to scripting support until a valid solution has been provided? I feel as if a solution would be reached at a faster rate if it were in the hands of programmers over builders. @buildthomas my apologies for bringing you into this conversation though I’m conflicted on this decision and you’ve assisted me with similar problems in the past so should I just remain patient until a solution is reached or can I temporarily move this topic to scripters support?

The error you have is unrelated to the code provided to you above. That error is coming from a plugin. It’s also unclear what the problem is; if you’re encountering an issue, then you need to specify what the problem is. Showing an error log isn’t sufficient enough except in cases where visuals are irrelevant.

If the error is irrelevant to @tronP’s than the code didn’t work. The problem is that I’m trying to achieve what you had suggested in the thread I referenced earlier.

  • Haven’t attempted to increase the height as it would force me to revision the entire build as the original had a tight space in mind throughout the design process.
  • Had attempted to place the spawn below the floor which failed.
  • Through the process of trial and error I’ve come to the conclusion that to achieve the best results I should resort to cframing the character.

The reason why I failed to script it myself is due to how my learning disability has interfered with solving a simple problem like this. I’m open to any amount of assistance, whether it be providing sources of information for me to better understand the problem or voluntarily supplying a functioning script that’ll allow me to continue to modify my build as I had intended from the start.

If you’re trying to spawn the player inside a terrain body of water, your only option is that last one. The others won’t work because internally the character is moved in such a way that they are able to be placed in a non-obstructed region of a spawn. Terrain voxels are counted as obstructions hence why your character is placed above the water and not directly on the spawn in the water.

There’s still a lack of details here so it’s not that clear what kind of issue you’re experiencing. How is the code not working? What does your current implementation look like? Do you still spawn above water? Are you able to confirm that your character isn’t just floating up and that even after resetting and respawning, it spawns you above water?

Characters will float in water if left idle.

Yes, I’m still floating to the top rather than spawning on the XYZ access that the script was supposed to place my character at. FYI, At the beginning of this post I provided the place file for others to further investigate this problem if interested. Not to sound ungrateful or anything for the feedback you’ve provided so far, however wouldn’t it be more time efficient if you checked the file out yourself to validate if the code had worked as intended?

The code provided by @tronP earlier didn’t work when the terrain water was removed. So unless I’m doing something wrong than it just doesn’t work as intended. In the visual above, I attempted to spawn on the red neon part which failed.

in ServerScriptService add a script that says this, this should work.

local players = game:GetService("Players")

local spawnPart = workspace.spawnPart --set this to the spawn

players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function(character)
		wait()
		character:SetPrimaryPartCFrame(spawnPart.CFrame)
	end)
end)

If your character can fit in the tunnel, this should work
p.s. I would only use :SetPrimaryPartCFrame on a model that has a humanoid in this case, otherwise use character:MoveTo()

edit: I just tested the script in your place, you will have to rise the spawn location a little so the character does not get stuck in the bottom of the tunnel, or add a Vector3.new(0, 1, 0) to the spawnPart.CFrame

2 Likes