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