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

Gui isn't working?

Asked by 8 years ago

local Player = game.Players.LocalPlayer local Debris = game:GetService('Debris') local Main = script.Parent.MainWindow local Mouse = Player:GetMouse() local Cam = game.Workspace.CurrentCamera local Events = game.Workspace.Events local Items = game.ReplicatedStorage.Modules_Basic TeamChange = Player.PlayerGui.TeamChange HMA = TeamChange.HMA Raiders = TeamChange.Raiders Player.CharacterAdded:wait() -- Adds a few bits of back-up, -- // Faction Settings Pos = Main.Factions_Frame.Example_Log.Position OnFirst = true -- Grabs all the factions, for i,v in pairs(Items.Factions:GetChildren()) do if OnFirst == true then local new_log = Main.Factions_Frame.Example_Log:Clone() new_log.Parent = Main.Factions_Frame new_log.Text = v.Faction_Name.Value new_log.Name = v.Name new_log.Position = Pos new_log.Visible = true new_log.Faction_Info.Text = v.Faction_Info.Value wait(0.005) Pos = new_log.Position OnFirst = false if player:IsInGroup(127081) then HMA.MouseButton1Down:connect(function() Player.TeamColor = BrickColor.new("Cyan") Player.Character:BreakJoints() end) else local new_log = Main.Factions_Frame.Example_Log:Clone() new_log.Parent = Main.Factions_Frame new_log.Text = v.Faction_Name.Value new_log.Faction_Info.Text = v.Faction_Info.Value new_log.Name = v.Name new_log.Position = Pos + UDim2.new(0,0,0,60) new_log.Visible = true wait(0.005) Pos = new_log.Position end end -- // Faction Settings

So I am trying to make it where if you click on the gui button you will join the team if your in a certian group but for some odd reason it won't work. Anyone mind helping?

1 answer

Log in to vote
0
Answered by 8 years ago

Notes:

-You should consider using WaitForChild to avoid issues where objects don't yet exist but the script is running anyway (a common source of errors)

-:GetMouse() is deprecated, consider rewriting your code to use (UserInputService)[http://wiki.roblox.com/index.php?title=API:Class/UserInputService], or just use gui object events (like MouseButton1Down, which you use in the code shown).

-The smallest time 'wait' will wait for is around 0.03 seconds (though it will sometimes wait for more or less time than that). If you just want the smallest possible wait, use "wait()".

-Your usage of Player.CharacterAdded:wait() might cause the localscript to wait until the player has respawned, depending on whether Roblox runs this script before or after spawning the player's character. Consider only doing that if the player's Character is nil (if you even need it at all).

-To debug, make sure your Output window is open (in case there are any bugs). If there aren't any bugs when you run the script (that show up), add print statements to sections of code to make sure they are running and to determine the value of variables. Ex, if you put a print statement on line 13 and it never showed up, you'd know that the Player.CharacterAdded:wait() line is not returning, which would prove that the player's character is already loaded when this script runs.

0
Okay when I use spawns in game it will remove the teams gui AthoronTheBrave 45 — 8y
Ad

Answer this question