Hey, guys. The following script is suppose to clone a Gui inside a tool and copy it to the Player's PlayerGui whenever the tool is activated (clicked once after the tool is equipped). It works perfectly in Roblox Studio, but not in the real game. If anyone explain to me what is wrong, I would gladly appreciate it.
Tool = script.Parent
Player = Tool.Parent.Parent
Character = Player.Character
mouse = Player:GetMouse()
Gui = Tool.AmmoGui
Tool.Equipped:connect(function(mouse)
findGui = Player.PlayerGui:FindFirstChild("AmmoGui")
if findGui then
findGui.Frame.Visible = true
else
newGui = Gui:Clone()
newGui.Parent = Player.PlayerGui
end
end)
Tool.Unequipped:connect(function(mouse)
findGui = Player.PlayerGui:FindFirstChild("AmmoGui")
if findGui then
findGui.Frame.Visible = false
else
print("AmmoGui wasn't found")
end
end)

1 comment
Maybe because you define mouse, when in actual fact the equipped event also returns you mouse. Try not defining mouse