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

Giving a user a hat that the user doesn't own? [Solved!]

Hi, I'm kind of new to this site and RBX.Lua, so any help is appreciated.

I want to put a hat on a specific user a hat that the user doesn't own, and only for that user.

I've tried using the

game.Players.PlayerAdded:connect(function(player)

end)

, but that doesn't seem to work.

If you could put it in the most simplest terms, that would be great. Thanks.

3 answers

✓ Accepted answer

Use InsertService to load a hat and get the first child of the model the function returns and add it to the player's character. The hat will be correctly welded to them automatically.

game.Players.PlayerAdded:connect(function(player)
	repeat wait()until player.Character
	local hatId=1045408
	if player.Name=="1waffle1"then
		hatId=21070012
	end
	local hat = game:service("InsertService"):LoadAsset(hatId):GetChildren()[1]
	hat.Parent=player.Character
end)

3 comments

0

The button on ROBLOX Studio won't give me the "InsertService" service? Or do I do something else to get the InsertService?

0

game:GetService("InsertService"):LoadAsset(hatId):GetChildren()[1].Parent=Character

0

OK, but how would I give that hat to only one specific player?

Scripting Helpers is helping to fix a Script. So please only ask to fix a Script. You are asking for someone to make something for you thats not allowed. Thanks,

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