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

Why is this Teleporting Script not Working?

Asked by 8 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 8 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 2460 — 8y
0
Thanks! CoolJohnnyboy 121 — 8y
0
Wait, I still have the same issue in online mode. It won't teleport the player. CoolJohnnyboy 121 — 8y
0
Press F9. It should come up with the dev console, and you can see the error. TheDeadlyPanther 2460 — 8y
Ad
Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
8 years ago

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

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

Answer this question