Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my teleport script would only teleport player once?

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)

2 comments

0

Your indentation is a bit of a mess here.

0

At least its somewhat readable

1 answer

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

3 comments

0

Why does he even need to use a remote? Just teleport on the client, no?

0

Also, this doesn't look like what he's going for.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.