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 9 years ago

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

Tool = function(onEquipped)
local LocalScript=script.Parent
local plr=game.Players.LocalPlayer
plr.PlayerGui = Instance.new("ScreenGui")
plr.PlayerGui.ScreenGui = Instance.new ("Frame")
plr.PlayerGui.ScreenGui.Frame.Position = UDim2.new(0.7, 0,0.78, 0)
plr.PlayerGui.ScreenGui.Frame.Size = UDim2.new(0.3, 2,0.2, 10)

end

Any ideas?

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

1 answer

Log in to vote
0
Answered by
Invisum -5
9 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:

tool= script.Parent
plr=game.Players.LocalPlayer
function onEquipped()
local a =Instance.new("ScreenGui")
a.Parent = plr.PlayerGui
a.Name = "Ammo"
local b = Instance.new ("Frame")
b.Parent = plr.PlayerGui.Ammo
b.Name = "AmmoFrame"
b.Position = UDim2.new(0.7, 0,0.78, 0)
b.Size = UDim2.new(0.3, 2,0.2, 10)
end

function onUnequipped()
if plr.PlayerGui.Ammo ~= nil then
plr.PlayerGui.Ammo:Destroy()
end
end
tool.Unequipped:connect(onUnequipped)
tool.Equipped:connect(onEquipped)



Ad

Answer this question