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

Why doesnt this script teleport the player?

Asked by 4 years ago

I have made the following script, it needs to teleport the player from one world to another, however, it does not work. This script is a localscript. The reason for all of the different things is that the parts lie inside a model, named DannebrogStill.

local TeleportService = game:GetService("TeleportService")
local placeID_1 = 751068488
local player = game.Players.LocalPlayer

while true do
game.Workspace.DannebrogStill.End.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.Head.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.Middle.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.NearMiddle.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.Second.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.Third.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)

game.Workspace.DannebrogStill.Torso.Touched:Connect(function(part)
    if part.Parent.HumanoidPlayer then
        TeleportService:Teleport(placeID_1, player)
    end 
end)
end
0
What doesn't work? Does it give an error or anything? IceAndNull 142 — 4y
0
Can you post a screenshot of the parts? BashGuy10 384 — 4y
0
can you reply with the output? YahiaElramal_77 26 — 4y
0
ye that to BashGuy10 384 — 4y
0
thats for a localscript use something like game.Players:GetPlayerFromCharacter(part.Parent.HumanoidPlayer) but you should also define the HumanoidPlayer TrustedInstaIler 17 — 4y

2 answers

Log in to vote
0
Answered by
Kblow1 53
4 years ago
Edited 4 years ago

Try this, if this doesnt work. Reply with the error.

local TeleportService = game:GetService("TeleportService")
local placeID_1 = 751068488
local player = game.Players.LocalPlayer

while wait() do
    game.Workspace.DannebrogStill.End.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.Head.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.Middle.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.NearMiddle.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.Second.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.Third.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)

    game.Workspace.DannebrogStill.Torso.Touched:Connect(function(part)
        if part.Parent.HumanoidPlayer then
            TeleportService:Teleport(placeID_1, player)
        end 
    end)
end
Ad
Log in to vote
0
Answered by 4 years ago

I suggest making it a script instead of local script. If you do, I think this code is what you are looking for.

(BTW this teleports the player to a place when they touch it. You will have to modify the gameID)


local TeleportService = game:GetService("TeleportService") local gameID = 3869185466 --put place id here function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then TeleportService:Teleport(gameID, player) end end script.Parent.Touched:connect(onTouched)

Answer this question