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 5 years ago
Edited 5 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

01local repStorage = game:GetService("ReplicatedStorage")
02local remote = repStorage:WaitForChild("remote",400)
03local InsertService = game:GetService("InsertService")
04function getItemFromId(id)
05    for _,v in pairs(game.ReplicatedStorage.Items:GetChildren()) do
06        if v.ItemId.Value == id then
07            return v.Name
08        end
09    end
10end
11remote.OnServerEvent:Connect(function(player, ItemID, GiveTo, Amount)
12    local plr = GiveTo
13    local ItemId = tonumber(ItemID)
14      print(plr)
15      print(player.Name)
16      print(getItemFromId(ItemId))
17    game.ServerStorage.AwardItem:Invoke(plr, ItemId, Amount)
18    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 — 5y

Answer this question