Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.