Hello, I have a basic fix but I don't know if it is correct. What would you do too be able too actually make this function and work as a item giver in Miners Haven

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("remote",400)
local InsertService = game:GetService("InsertService")
function getItemFromId(id)
    for _,v in pairs(game.ReplicatedStorage.Items:GetChildren()) do
        if v.ItemId.Value == id then
            return v.Name
        end 
    end
end
remote.OnServerEvent:Connect(function(player, ItemID, GiveTo, Amount)
    local plr = GiveTo 
    local ItemId = tonumber(ItemID)
      print(plr)
      print(player.Name)
      print(getItemFromId(ItemId))
    game.ServerStorage.AwardItem:Invoke(plr, ItemId, Amount)
    game.ReplicatedStorage.Hint:FireClient(plr, player.Name.." has given you".. getItemFromId(ItemId))

If you can answer this question please do, I would love too hear back from you.. I cannot do this by myself and need help, try too be thorough and very detailed, I have a hard time actually like knowing what people are talking about so, if you can answer this in some way I will understand that would be greatly appreciated

I tried doing local plr = (ItemID,Amount,Player) GiveTo but I know that is wrong and can't seem too get it down..

1 comment

0

you already defined player in the function