Hi. I am making an FPS on ROBLOX. I was trying to make a script where when somebody clicks the "Deploy" button... it teleported the players character from the pre - area to an actual spawn in the game. I didn't want to kill the person to send them there s I used the CFrame technique. My problem is I keep getting an error message. Here's my script:
local button = script.Parent --Deploy Button
local plrs = game:GetService("Players") --Gets Players Service
local player = game.Players.LocalPlayer --Defines The Local Player
local numofspwns = 10 --The Number Of Spawns
local target = game.Workspace.MapSpawns[math.random(1, 10)] --Defines what tp brick will be chosen
local function Teleport() --Function For TP
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, 5, 0)
end
end
local function Spawn() --Defines What A Spawn Is (I didn't include any other code to prevent copiers.)
button.Parent.Parent.Enabled = nil
Teleport()
end
local function onButtonClick() --When clicked...
Spawn() --Spawn.
end
button.MouseButton1Click:connect(onButtonClick) --Defines onButtonClick() func.
The Error message I keep getting is: 22:28:38.921 - Players.ScrappyFriend77.PlayerGui.ScreenGui.MainFrame.Deploy.LocalScript:9: bad argument #1 to '?' (Vector3 expected, got Object)
Full Output: 22:28:38.921 - Players.ScrappyFriend77.PlayerGui.ScreenGui.MainFrame.Deploy.LocalScript:9: bad argument #1 to '?' (Vector3 expected, got Object) 22:28:38.922 - Stack Begin 22:28:38.924 - Script 'Players.ScrappyFriend77.PlayerGui.ScreenGui.MainFrame.Deploy.LocalScript', Line 9 - upvalue Teleport 22:28:38.925 - Script 'Players.ScrappyFriend77.PlayerGui.ScreenGui.MainFrame.Deploy.LocalScript', Line 15 - upvalue Spawn 22:28:38.927 - Script 'Players.ScrappyFriend77.PlayerGui.ScreenGui.MainFrame.Deploy.LocalScript', Line 19 22:28:38.929 - Stack End
Thanks for taking your time to see this. Whoever answers this will get an extra perk in the game. Thanks again. (Perk will probably be access to all guns. I'm a nice guy. lol)

2 comments
I know about the stacks. But thx.
Thx but it didn't work. i solved it myself but with ur help. So ill accept your answer and while in developing ill give your profile an all access pass to the game ok?