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

my teleport script would only teleport player once?

Asked by
0msh 333 Moderation Voter
6 years ago

so if I teleport to "Island1" first, I can teleport to "Island1" again, but I can't teleport to "Island2" after I teleport to "Island1", same goes for the other way around...

local island1 = script.Parent:FindFirstChild("1")
local island2 = script.Parent:FindFirstChild("2")
local player = script.Parent.Parent.Parent.Parent
local teleport = player:FindFirstChild("SS").Teleport
local d = false
local c = false
island1.MouseButton1Down:Connect(function()
    if d == false then
    d = true
    if teleport.Value >= 0 then
        player.Character:FindFirstChild("Torso").CFrame = game.Workspace.Island1.CFrame
        for i = 30,0,-1 do
        island1.Text = i
        wait(1)
        if i <= 0 then
            d = false
        end
        end
    end
    end
end)
island2.MouseButton1Down:Connect(function()
    if c == false then
    c = true
    if teleport.Value >= 1 then
        player.Character:FindFirstChild("Torso").CFrame = game.Workspace.Island2.CFrame
        for i = 30,0,-1 do
        island2.Text = i
        wait(1)
        if i <= 0 then
            c = false
        end
        end
    end
    end
end)
0
Your indentation is a bit of a mess here. OldPalHappy 1477 — 6y
0
At least its somewhat readable User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I think you're overcomplicating this, you just want to teleport between two islands when they are clicked on? I don't know exactly what you want but you could take mouse input from a local script and use a server script to execute the teleport

Example:

Server Script:

game.ReplicatedStorage.RemoteEvents.Teleport.OnServerEvent:connect(function(plr,hit)
    plr.Character:SetPrimaryPartCFrame(hit.CFrame+Vector3.new(0,4,0))
end)

Local Script:

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:connect(function()
    if mouse.Target.Name == "P1" or mouse.Target.Name == "P2" then
        game.ReplicatedStorage.RemoteEvents.Teleport:FireServer(mouse.Target)
    end
end)

Again, I don't really know exactly what you're trying to do but there ya go

0
Why does he even need to use a remote? Just teleport on the client, no? OldPalHappy 1477 — 6y
0
Also, this doesn't look like what he's going for. OldPalHappy 1477 — 6y
0
I don't think you can teleport on the client with FE enabled, and I didn't really see what he was going for BlizzardBan 15 — 6y
Ad

Answer this question