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

Ammo GUI Not Working?

Asked by 10 years ago

I made sure I did this right. There are no errors in Output or Script Analysis.

1Tool = function(onEquipped)
2local LocalScript=script.Parent
3local plr=game.Players.LocalPlayer
4plr.PlayerGui = Instance.new("ScreenGui")
5plr.PlayerGui.ScreenGui = Instance.new ("Frame")
6plr.PlayerGui.ScreenGui.Frame.Position = UDim2.new(0.7, 0,0.78, 0)
7plr.PlayerGui.ScreenGui.Frame.Size = UDim2.new(0.3, 2,0.2, 10)
8 
9end

Any ideas?

0
There are many, many problems here. I suggest you review your basics. Perci1 4988 — 10y

1 answer

Log in to vote
0
Answered by
Invisum -5
10 years ago

Your code is wrong. Your function is not complete and the way you want to make the GUI is wrong. Also you don't have an unequip function and a code that will remove the GUI when a player unequips the weapon. I corrected your code, I removed mistakes, I completed the function and I added an unequip function wtih 2 simple lines of code that remove the GUI when the player unequips the weapon. To make the script work, you would have to paste the code that I wrote for you in a script (not a local script) and have a Handle for your weapon. Script:

01tool= script.Parent
02plr=game.Players.LocalPlayer
03function onEquipped()
04local a =Instance.new("ScreenGui")
05a.Parent = plr.PlayerGui
06a.Name = "Ammo"
07local b = Instance.new ("Frame")
08b.Parent = plr.PlayerGui.Ammo
09b.Name = "AmmoFrame"
10b.Position = UDim2.new(0.7, 0,0.78, 0)
11b.Size = UDim2.new(0.3, 2,0.2, 10)
12end
13 
14function onUnequipped()
15if plr.PlayerGui.Ammo ~= nil then
16plr.PlayerGui.Ammo:Destroy()
17end
18end
19tool.Unequipped:connect(onUnequipped)
20tool.Equipped:connect(onEquipped)
Ad

Answer this question