Hello i want to do a module function to add item to a player and it work the frame appear but the event mousebutton1click don’t work (this is a script)
Image is an ImageButton
function module:ItemAdd(plr:Player,Item,Amount:IntValue)
Amount = Amount or 1
assert(Items[Item],"Item is not register")
local Inv = plr.PlayerGui.Inventory.ItemBox.ScrollingFrame
local Object = Inv:FindFirstChild(Item)
if Object then --Item in inventory
PlayersInventories[plr.UserId][Item] += Amount
Object.Amount.Value += Amount --Add Amount
else --Item not in inventory
if not PlayersInventories[plr.UserId] then PlayersInventories[plr.UserId] = {} end
PlayersInventories[plr.UserId][Item] = Amount
Object = Inv.Parent.Parent.Template.Template:Clone() --Create item
Object.Parent = Inv
Object.Amount.Value = Amount
Object.Masse.Value = Items[Item]["Masse"]
Object.Image.Image = Items[Item]["Image"]
Object.Name = Item
Object.Frame.ItemName.Text = Item
Object.Visible = true
end
Object.Frame.Quantity.Text = Object.Amount.Value
Object.Image.MouseButton1Click:Connect(function()
print("Click")
end)
if Object.Amount.Value <= 0 then
PlayersInventories[plr.UserId][Item] = nil
Object:Destroy()
end
end
Just in case i tried in client and it work but i don’t understand why it don’t work in server while in other of my game it is working