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

How can I find the player and give him the item?

Asked by 5 years ago

I made a button that gives player an item. The item is in "ServerStorage" , and I am cloning the item.

local button = script.Parent.Parent

script.Parent.MouseClick:connect(function()
    print("hey")
    local copy = game.ServerStorage.BlOcK:Clone()
    copy.Parent = game.Players.Player1.Backpack
end)

Model > Button > ClickDetector > Script | ServerStorage > Tool

Player1 is the player I want to give him the item. I dont know how to make it work. Please help. Thank you. :)

1 answer

Log in to vote
1
Answered by 5 years ago

Try using this:

script.Parent.MouseClick:connect(function(plr)
        local copy = game.ServerStorage.BlOcK:Clone()
copy.Parent = plr.Backpack
end)

So what this does is that it clones the tool to the player who clicks the button. Sorry if I misunderstood your question. P.S Also sorry about the bad indentation, I'm on mobile right now.

Ad

Answer this question