This probably means that your picked_value object isn’t being translated into a Vector3 correctly. Try doing print(Vector3.new(picked_value)) and see what happens. If your picked_value has coordinates, you may want to individually assign them to the vector.
What I meant in the last sentence is that if pick_value is already a vector, you don’t have to put Vector3.new() before it because then it will make a new 0,0,0 vector which is what the screenshot was trying to show.
If your picked_value is already a vector, then your script would just be
CFrame.new(picked_value) instead of CFrame.new(Vector3.new(picked_value))
this is the script I create the value in (Sorry for it being messy, I’m still new to scripting)
local Spawnloc1 = CFrame.new(64.65, 16105.011, -3289.95)
local Spawnloc2 = CFrame.new(114.65, 16105.011, -3289.95)
local Spawnloc3 = CFrame.new(164.65, 16105.011, -3289.95)
local Spawnloc4 = CFrame.new(214.65, 16105.011, -3289.95)
local Spawncords = {Spawnloc1, Spawnloc2, Spawnloc3, Spawnloc4}
print(Spawncords)
print(Spawncords[1])
print(Spawncords[2])
print(Spawncords[3])
print(Spawncords[4])
local value = math.random(1,#Spawncords) -- Get random number with 1 to length of table.
local picked_value = Spawncords[value] -- Pick value from table
print(picked_value)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteEvent = ReplicatedStorage:WaitForChild("PlayerJoined")
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
print("A player has entered: " .. player.Name)
print(picked_value)
print("lmao")
remoteEvent:FireClient(player, picked_value)
end)
okay, so I saw that and realized that this should work
--Anchor head and stop player from moving
repeat wait() until lplayer.Character
local char = lplayer.Character
local head = char:WaitForChild('Head')
char.HumanoidRootPart.CFrame = picked_value
print(picked_value)
head.Anchored = true
print("Your head should be anchored")
local humanoid = char.Humanoid
humanoid.WalkSpeed = 0
end
-- Call "onNotifyPlayer()" when the server fires the remote event
remoteEvent.OnClientEvent:Connect(onfreezeplayer)
but it just makes my character spawn at the world origin rather than teleporting them to the correct location (to the Cframe)
local value = math.random(1,#Spawncords) -- Get random number with 1 to length of table.
local picked_value = Spawncords[value] -- Pick value from table
print(picked_value)
Move this inside of PlayerAdded so that it runs every time a new player joins. To be clear though, this means that each player gets assigned a spawnpoint when they join, and they will always spawn at that location.
Can I see the full script from your most recent post?
thank you, and which script are you referring to? If it’s the one that I made the original post about, then this is it.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("PlayerJoined")
-- Ignore the passed player; start with additional passed data
local function onfreezeplayer(picked_value)
print(picked_value)
print("lmao")
local lplayer = game.Players.LocalPlayer
print(lplayer)
local spawnbox = CFrame.new(179.5, 16108.009, -3258.5)
lplayer:RequestStreamAroundAsync(spawnbox.Position)
print("Picked value:")
print(picked_value)
print("Incoming server event...")
picked_value = picked_value
--change cam
local Players = game:GetService("Players")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local WFC = game.ReplicatedStorage:WaitForChild("SB1cam")
camera.CFrame = game.ReplicatedStorage.SB1cam.CFrame
--Anchor head and stop player from moving
repeat wait() until lplayer.Character
local char = lplayer.Character
local head = char:WaitForChild('Head')
char.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(picked_value))
print("devforum info")
print(char.HumanoidRootPart.CFrame)
print("^char")
print(CFrame.new(Vector3.new(picked_value)))
print("^Cframe.vector")
print((Vector3.new(picked_value)))
print("vec3")
print(CFrame.new(picked_value))
print("^Cfram.new")
print(picked_value)
head.Anchored = true
print("Your head should be anchored")
local humanoid = char.Humanoid
humanoid.WalkSpeed = 0
end
-- Call "onNotifyPlayer()" when the server fires the remote event
remoteEvent.OnClientEvent:Connect(onfreezeplayer)
ignore any random prints lol, those are just there for personal reference.
You wouldn’t convert to radians if you are using the position part of the CFrame. And CFrame.new absolutely can use a Vector3.
@mcox6 when is this supposed to teleport the player to the spawns? Whever the character loads? Or is it supposed to be conditional on the ‘freezeplayer’ deal or something like that?
when the player loads in, it teleports them to what I call a “Spawn box” That’s where they can customize their player, before fully spawning onto the map.