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

How to make a teleporter + How to make the button debounce?

Okay this is a DOUBLE-PROBLEM question. So I have been working on this problem for two weeks now and I can't manage to find any solution on the research that I have gathered. Basically, this is a Team Changer GUI and my problems are:

First problem the teleporter works on sometimes when you pressed the button, but often will find yourself in the same spot.

Second problem the debounce for TeamJoined is not working at ALL.

No errors are given in the output box.

ClassHolder = script.Parent --Frame
ct = ClassHolder.CounterTerrorists --Button
t = ClassHolder.Terrorists --Button
ctspawn = game.Workspace.ctspawn --SpawnPoint 1
tspawn = game.Workspace.tspawn --SpawnPoint 2
player = game.Players.LocalPlayer

Teamjoined = false

ct.MouseButton1Down:connect(function()
	if Teamjoined == false then
		player.TeamColor = BrickColor.new('Really blue')
		player.Character:MoveTo(ctspawn.Position)
		player:LoadCharacter()
		ClassHolder.Visible = false
		Teamjoined = true
	elseif Teamjoined == true then
		print('You already joined a team')
	end
end)	

t.MouseButton1Down:connect(function()
	if Teamjoined == false then
		player.TeamColor = BrickColor.new('Really red')
		player.Character:MoveTo(tspawn.Position)
		player:LoadCharacter()
		ClassHolder.Visible = false
		Teamjoined = true
	elseif Teamjoined == true then
		print('You already joined a team')
	end
end)

Thanks for the help.

3 comments

0

MoveTo will make them walk to the point. Here's a good idea: Change their team, put spawns for that team. Then, use game.Players.PLAYERNAME:LoadCharacter() and it will basically reset the character without the death animation and such, like the respawn command in admin scripts.

0

And by the above, I mean remove the "moveto" part. Make sure "tspawn" is a spawnlocation of the variety "Really red". To make it debounce just type debounce = true.

0

@shayner: MoveTo only makes them walk to the specified point if you apply it to a humanoid. In this case, it should work fine since it's being applied to the character model.

1 answer

An effective way of teleportation is this:

local tp = game.Workspace.TPPart

game.Players.PlayerAdded:connect(function(p)
	p.CharacterAdded:wait()
	p.Character.Torso.CFrame = Vector3.new(tp.Position.X,tp.Position.Y + tp.Size.Y / 2 + 7,tp.Position.Z) -- This teleports the player, and makes the character on top of the object, no matter how tall it is.
end)

I cannot find the error in the debounce part, so here's an effective way to debug it:

The best way to debug things with no error output is to put lots of print()s into the script, to see where/how far it goes.

E.G

print("ok")
local num = 5
print("ok2")
if num == 4 then
	print("ok3")
end

Hope I helped :)

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