Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

in the 12th line of code, I need help trying too get the *GiveTo* too work. How do you do it?

Asked by 4 years ago
Edited 4 years ago

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..

0
you already defined player in the function relatlves 17 — 4y

Answer this question