I’ve been having an issue where the spawn point spawns me in mid air above the spawn point. I believe this is because I have the spawn point inside a part, with can-collide equal to false. Is there a way where I can fix this potentially? The can-collide part is intended for the games functionality (music regions), so It’d be a bummer if this is unable to be fixed. If you need me to inform you with more details, let me know.
This isn’t a scripting issue, more of a game design issue.
Spawn points create players above their center point, but if that spawn point is in another Part(s) it’ll create them above that Part(s).
How big is the Part you are spawning above? I’m guessing big enough to create a noticeable drop when you join.
Are the music regions controlled by the size of the Part?
Like is it at a low height? If it is, Spawnpoints have a terrible bug where if it is below a certain physical distance in the actual game, they spawn you where the bug just begins.
The spawn is in the part which is ten times larger than it. I’m making an obby game, and when the player dies, it re-spawns at every checkpoint in mid-air above the checkpoint they were last at because of the sound region covering the area.
while wait(.5) do
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
local sound = script.Parent.SoundRegions[v.Name]
Found = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
print("Player Was Found")
Found = true
break
else
Found = false
print("Player Not Found")
end
end
Update on everything we know so far. This is what’s causing this issue:
Creating collision groups are essential to fixing this problem, however my checkpoints are custom (so is the spawn point), so it still doesn’t work for that reason being probably. (it works if you’re using normal spawn points)
After testing a few more things, it seems to me that its the obby script is the one thats breaking this which is the main script for things such as the datastores, check-points, leaderstats, etc. I’ll provide the the obby script below because I’m still unsure that’ll I’ll be able to solve this myself. Let me know if you want more information on the script, or anything in general surrounding this issue.
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[v.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints and char.Humanoid.Health ~= 0 then
if tonumber(hit.Name) == v.Value +1 then
v.Value = v.Value +1
end
elseif hit.Parent == workspace.Objects.Kills then
char.Humanoid.Health = 0
end
end)
end)
You could just teleport the user to the spawn point right as they load.
workspace.ChildAdded:Connect(function(c)
if game.Players:FindFirstChild(c.Name) then -- in case it isn't a player
c:SetPrimaryPartCFrame(CFrame.new(workspace.SpawnLocation.Position+Vector3.new(0,5,0)))
end
end
This will probably work if the user resets, I am unsure if it works when the user joins but use CharacterAdded if it doesn’t work the first time.
I’m sure you’ve figured this out by now or have moved on to other projects but just in case I think I might know how to fix your problem.
You’re using Model:MoveTo() to move your character. This function avoids allowing the model to intersect with other parts.
What I would recommend is setting the CFrame of your character’s HumanoidRootPart instead. This ignores collision (which means you could get stuck in a wall if that’s where you try to teleport.)
local hum = char:WaitForChild("Humanoid")
wait()
local RootPart = char:WaitForChild("HumanoidRootPart")
RootPart.CFrame = CFrame.new(checkpoints[v.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints and char.Humanoid.Health ~= 0 then
if tonumber(hit.Name) == v.Value +1 then
v.Value = v.Value +1
end
elseif hit.Parent == workspace.Objects.Kills then
char.Humanoid.Health = 0
end
end)
end)
This might also be a non-issue now because I can’t seem to recreate the issue with characters spawning above can-collide false parts when using a regular spawn point so perhaps the MoveTo function doesn’t do this anymore either. I don’t know, I haven’t tested.
I’ve found that using an R6 character caused this to happen to me, but using R15 fixes it. I wish there was an ignore obstructions function so you can just spawn inside the part. The only way to fix this is to create your own spawning system to overtake roblox’s spawning system, or use Region3.