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

How can I make a suitcase tool hit a block then teleport to the coordinates wanted?

Asked by 8 years ago

Here's what someone said would work. I'm NOT a scripter but he said to put this in the block and when the Suitcase tool hit it, it'd teleport to where I want. How would this be able to work?

bin = script.Parent

function teleportPlayer(pos)

    local player = game.Players.LocalPlayer
    if player == nil or player.Character == nil then return end

    local char = player.Character.Torso

    char.CFrame = CFrame.new(Vector3.new(pos.x, pos.y + 7, pos.z))

end


enabled = true
function onButton1Down(mouse)
    if not enabled then
        return
    end

    local player = game.Players.LocalPlayer
    if player == nil then return end
    local cf = mouse.Hit
    teleportPlayer(cf.p)

end

function onSelected(mouse)
    mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

0
I also tried changing player to tool but nothing. VirtualFlying 55 — 8y
0
Edited to fix formatting. BlueTaslem 18071 — 8y
0
Thanks :3 VirtualFlying 55 — 8y

Answer this question