New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why is this Teleporting Script not Working?

Asked by 4 years ago

This script is supposed to teleport the player, anchor their torso, give them a weapon and equip it for them, and then unanchor the torso.

However, the script doesn't teleport you; it does everything but that.

I have no idea why this script isn't working properly, and output gave me nothing.

Can someone please help me?

Here's the script:

local Player = script.Parent.Parent.Parent.Parent.Parent
local Primary = game.ReplicatedStorage.Guns.AK47:Clone()

function onButtonClicked()
if game.Workspace.Playing.Value == true then
Player.CameraMode = "LockFirstPerson"
Player.Backpack.Teled.Value = true 
    local torso = Player.Character.Torso
    spawns = {}
    for i,v in ipairs(game.Workspace.Map.SSpawns:GetChildren()) do
        if v.Name == "SSpawn" then
            table.insert(spawns,v)
        end
    end
    torso.CFrame = spawns[math.random(1,#spawns)].CFrame
 + Vector3.new(0,4,0)
    wait(0.1)
    torso.Anchored = true
    wait(0.1)
    Primary.Parent = Player.Backpack
    Player.Character.Humanoid:EquipTool(Player:WaitForChild("Backpack"):WaitForChild(Primary.Name))
    wait(0.1)
    torso.Anchored = false
    script.Parent.Parent.Parent:remove()
end
end

script.Parent.MouseButton1Click:connect(onButtonClicked)

2 answers

Log in to vote
1
Answered by 4 years ago

You cannot add a value to another value without defining which argument inside the value you're changing. Although, some things don't require you to define, it just automatically assumes what argument to use (normally just the first argument), like this:

torso.CFrame = spawns[math.random(1,#spawns)].Position + Vector3.new(0,4,0)

If you wanted to change more than just the position:

torso.CFrame = CFrame.new(spawns[math.random(1,#spawns)].Position, Vector3.new(0,0,0))
0
Notice the ',' TheDeadlyPanther 2438 — 4y
0
Thanks! CoolJohnnyboy 121 — 4y
0
Wait, I still have the same issue in online mode. It won't teleport the player. CoolJohnnyboy 121 — 4y
0
Press F9. It should come up with the dev console, and you can see the error. TheDeadlyPanther 2438 — 4y
Ad
Log in to vote
0
Answered by
FiredDusk 1465 Moderation Voter
4 years ago

There is an event called ":MoveTo" you could use that.

0
What would the script look like in that case? CoolJohnnyboy 121 — 4y

Answer this question