Does anyone know anything about getting info on a gui element to only show once?
Asked by
8 years ago Edited 8 years ago
I have been having trouble for the past week, here's how far i got before actually coming here to ask for help.The reason why i am here is because to get help on how to make sure it only displays some info once, and not over and over again.
This LocalScript handles everything to do with the player's GUI. In this case the event bar,
which displays information on the player's screen, such as who killed who with what.
001 | local Main = script.Parent.Parent.PlayerGui.Main |
002 | local BattleUI = script.Parent.Parent.PlayerGui.BattleUI |
003 | local LoTrig = game.ServerStorage.LoTrig |
007 | local EventBar = BattleUI.EventBar |
008 | local View = BattleUI.EventBar.View |
009 | local Bar = BattleUI.EventBar.View |
010 | local Bar 1 = View.Bar 1 |
011 | local Bar 2 = View.Bar 2 |
012 | local Bar 3 = View.Bar 3 |
013 | local Bar 4 = View.Bar 4 |
014 | local Bar 5 = View.Bar 5 |
022 | function EventFrameDisplay(K, D, Wep) |
026 | local LastWeapon = Wep |
029 | if Bar 1. Weapon.Text = = "NaN" and On 1. Value = = false then |
034 | elseif Bar 2. Weapon.Text = = "NaN" and On 2. Value = = false then |
040 | elseif Bar 3. Weapon.Text = = "NaN" and On 3. Value = = false then |
046 | elseif Bar 4. Weapon.Text = = "NaN" and On 4. Value = = false then |
052 | elseif Bar 5. Weapon.Text = = "NaN" and On 5. Value = = false then |
058 | if On 5. Value = = true then |
062 | Bar 5. Weapon.Text = Wep |
066 | Bar 5. Weapon.Text = "NaN" |
071 | if On 4. Value = = true then |
075 | Bar 4. Weapon.Text = Wep |
080 | Bar 4. Weapon.Text = "NaN" |
085 | if On 3. Value = = true then |
089 | Bar 3. Weapon.Text = Wep |
094 | Bar 3. Weapon.Text = "NaN" |
099 | if On 2. Value = = true then |
103 | Bar 2. Weapon.Text = Wep |
108 | Bar 2. Weapon.Text = "NaN" |
113 | if On 1. Value = = true then |
117 | Bar 1. Weapon.Text = Wep |
122 | Bar 1. Weapon.Text = "NaN" |
127 | if Bar 2. Killer = = Bar 1. Killer and Bar 2. Killed = = Bar 1. Killed and Bar 2. Weapon = = Bar 1. Weapon then |
146 | LoTrig.Event:connect(EventFrameDisplay) |
151 | LoTrig:Fire(LaLa, Land, AGun) |
This LocalScript is used to fire an event that triggers the function, EventFrameDisplay.
This method is used on my custom gun; to fire the LoTrig Event, which in turn, triggers the function that displays the information.
01 | hitHumanoid = findFirstClass(H.Parent, "Humanoid" ) |
03 | if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then |
04 | local Tag = Instance.new( "ObjectValue" ) |
07 | Tag.Parent = hitHumanoid |
09 | local chosenDamage = 0 |
10 | if H.Name = = "Head" then |
11 | chosenDamage = baseDamage * RAND(hVal, hVal + 0.1 , 0.01 ) |
12 | elseif H.Name = = "Torso" then |
13 | chosenDamage = baseDamage * RAND(cVal, cVal + 0.1 , 0.01 ) |
15 | chosenDamage = baseDamage * RAND(lVal, lVal + 0.1 , 0.01 ) |
17 | hitHumanoid:TakeDamage(chosenDamage) |
19 | elseif hitHumanoid and hitHumanoid.Health = = 0 and isEnemy(hitHumanoid) then |
21 | LoTrig:Fire(Player.Name, hitHumanoid.Name, script.Parent.Name) |
I have gotten it to work on the previous attempts, but it kept on sending information over and over like this if ran. The event was fired through my own custom gun, but i'll just leave an trigger within the script
This was put into a local script that was placed in game.StarterPlayer.StarterPlayerScripts.
Any answer related to this will be greatly aprecciated.
And if needed, you may ask for the gun script. Here's an piece.
EDIT: Forgot to include the link to the ui.
https://www.roblox.com/games/723299178/Get-ui-element-through-here