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

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

Asked by 8 years ago

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.

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. shayner32 478 — 8y
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. shayner32 478 — 8y
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. chess123mate 5873 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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 :)

Ad

Answer this question