How the heck I can make Dialog Hat Giver? I'm asking that, because there are only tutorials everywhere "How to make dialog tool/gun giver".
Put this script inside a Script
inside your dialog and make a dialog choice named "Hat";
HatId = 1708345137 -- Change this to the Had Id that you want script.Parent.DialogChoiceSelected:connect(function(Player,Choice) if Choice.Name == "Hat" then local Hat = game:GetService("InsertService"):LoadAsset(HatId) Hat:GetChildren()[1].Parent = Player.Character Hat:Destroy() end end)
How it works:
So first of all, this event activates when the player chooses a dialog choice. Then we check if the choice's name is "Hat". And if the player chooses "Hat" then the script will active. I used InsertService
to insert the Hat by it's AssetId. But with InsertService
it inserts the item inside a model. So since the Hat is inside a model, our "Hat" variable is equal to the model right now. So we just need what is inside the model, which is the hat. So we do GetChildren()
. That function returns a table of all children inside our model.To get the hat inside the model we would use GetChildren()[1]
. And now we set the the first child's (the hat) parent to the Player's character. And lastly, since we don't need the model anymore we just destroy is with Hat:Destroy()
.
Now if you have a hat in your game you want to give to the Player do this: (Make sure the Hat's Handle is not anchored!)
Hat = game.Workspace.Hat -- Set this to the hat object script.Parent.DialogChoiceSelected:connect(function(Player,Choice) if Choice.Name == "Hat" then Hat:Clone().Parent = Player.Character end end)