Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame Character into a spawnlocation not working for my Intermission Script?

Asked by 3 years ago

I have attempted to CFrame the player to a specific position into a generated map cloned to workspace once the Countdown reaches 1 without spawning inside the floor, however it is not working for me, can anyone help with this please? I also attempted to create a forcefield around the player, it also did not work. I don't what's wrong with my script.

Server Script in ServerScriptService

local countdown = game.ReplicatedStorage.Values:WaitForChild("countdown")

for i = 15,0,-1 do
    countdown.Value = i
    if i == 1 then
        local map = math.random(1,3)
        if map == 1 then
            game.ReplicatedStorage.Maps.Normal:Clone().Parent = workspace.Map
        end
        if map == 2 then
            game.ReplicatedStorage.Maps.Red:Clone().Parent = workspace.Map
        end
        if map == 3 then
            game.ReplicatedStorage.Maps.Green:Clone().Parent = workspace.Map
        end
        print(map)
        for i, v in pairs(game.Players:GetPlayers()) do
            local spawnLocation = workspace.Map.FindFirstChildOfClass("Model").SpawnLocation

            v.Character.Torso.CFrame = spawnLocation.CFrame(spawnLocation.Position.X, spawnLocation.Position.Y + 10, spawnLocation.Position.Z)
            local FF = Instance.new("ForceField")
            FF.Clone()
            FF.Parent = v.Character.Torso
            wait(5)
            FF:Destroy()
        end
    end
    wait(1)
end
0
am I missing something? L0RD_Bloxx -5 — 3y
0
There's a property of the player Player.RespawnLocation. https://developer.roblox.com/en-us/api-reference/property/Player/RespawnLocation and with the LoadCharacter function should achieve this https://developer.roblox.com/en-us/api-reference/function/Player/LoadCharacter MarkedTomato 810 — 3y
0
I tried Player:LoadCharacter() before but thanks for help, I will try looking through this. L0RD_Bloxx -5 — 3y
0
almost got it L0RD_Bloxx -5 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

It looks like you are trying to change the CFrame of the torso, which will not work since the player's primary part is the HumanoidRootPart. Therefore you would have to replace

v.Character.Torso.CFrame

with

v.Character.HumanoidRootPart.CFrame
Ad

Answer this question