#Cframe being weird

1 messages · Page 1 of 1 (latest)

lilac lily
#

So my game runs a round based system, where there is a time always increasing, and changing the state after certain defined time lengths

When a player is added, I set the character root part cframe at a lobby spawn point.

What happens is when it get to the countdown phase of the timer, before the game starts, it’s supposed to load the map and place all 10 players onto spawn point parts that are inside the map model located in a folder

A module script named “Mapmanager” runs, where i call the function getSpawnPoints. When going back to the original server script, i put prints everywhere to make sure there were no nil or wrong values. Everything came out as it should

The problem is, when it hits the countdown phase, it freezes players in place as it should, but it doesn’t teleport them to the spawn pint frames like it should.

The issue is weird because it runs completely fine, the prints came out clean and the code after an correctly, so it has to be just that line of code where it sets the CFrame of the root part of the character to the spawn point CFrame

I can send a video

faint nexus
#

Are you using character:PivotTo(destinationCframe)?

lilac lily
#

no, i set the humanoid cframe

#

yes i will send

#

thats the whole file, this is bit wiht the issue

#

``local function startCountdown()
currentState = "Countdown"
timeLeft = COUNTDOWN_TIME

-- Determine winning map and load it
local winningMap = getWinningMap()
MapManager:LoadMap(winningMap)

-- Initialize player tracking for this game
for _, player in pairs(getAllPlayers()) do
    
    alivePlayers[player.UserId] = player
    playersInGame[player.UserId] = true
    print(alivePlayers[player.UserId])
end
local aliveCount = countAlivePlayers()
print(aliveCount)
-- Get spawn locations for the new map
local spawnFolder = MapManager:GetCurrentSpawnFolder()
print(spawnFolder.Name)
-- Teleport players to map spawns and lock them in place
if spawnFolder then
    print("spawnedfound")
    local spawns = spawnFolder:GetChildren()
    print(spawns)
    if #spawns > 0 then
        for i, player in pairs(getAllPlayers()) do
            print(player.Name)
            if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
                local spawnIndex = ((i - 1) % #spawns) + 1
                local spawn = spawns[spawnIndex]
                player.Character.HumanoidRootPart.CFrame = spawn.CFrame + Vector3.new(0, 5, 0)
                print("spawned")
                -- Lock player in place during countdown
                if player.Character:FindFirstChild("Humanoid") then
                    player.Character.Humanoid.PlatformStand = true
                    player.Character.HumanoidRootPart.Anchored = true
                end
            end
        end
    end
else
    warn("No folder found")
end

-- Notify clients
roundStateEvent:FireAllClients("Countdown", winningMap)

print("Countdown started - loaded map: " .. winningMap .. " - players locked in place")

end``

faint nexus
#

This isn't how you should move the character player.Character.HumanoidRootPart.CFrame = spawn.CFrame + Vector3.new(0, 5, 0)

Do it like this: player.Character:PivotTo(spawn.CFrame + Vector3.new(0, 5, 0))

lilac lily
#

I’ll try that. Could you explain why??

#

what’s weird is it worked previously, then just broke randomly after adjusting a few things

lilac lily
#

Sadly that did not work.

I decided to completely remove the spawn player at lobby function and replaced it with your suggested code, and it worked in that instance.

but for some reason, it does not work with the parts

lilac lily
#

any ideas?

turbid rose
#

wait so your problem is that it freezes the players but doesn't teleport them?

#

are they supposed to teleport in the same spot

#

if there are more spawn points how much spawn points are there

lilac lily
#

yes, ten points

rapid grove