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?
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)