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

I think I'm the only one roblox player who ask for this. But maybe not?

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".

6 comments

0

I'm waiting for answers...

0

People! Dont be scared! I'm making a game and I want to know how to make that dialog hat giver!!!

0

People will answer your post eventually, dont post comments for no reason.

0

For no reason? WHAT THE ***? For no reason? Then why nobody is answering me huh?

0

1 hour later... Still waiting for answers...

0

finally someone answered me! Thank you MRbraveDragon!

1 answer

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)

15 comments

0

Ok im going to test that in roblox studio.

0

Sorry about the unnecessary print. I was using it for debugging

0

Ok now question. Can I put that script inside Dialog Choice?

0

ok nevermind I noticed now that you said that.

0

Yes you can. But I would not recommend it. Because there is no event for checking if a specific choice got selected. https://wiki.roblox.com/index.php?title=API:Class/DialogChoice

0

OMG It worked! Thank you so much!!! :D

0

No problem!

0

Ok, but I normally created the script inside "Dialog" not "DialogChoice".

0

Wait I noticed that I also maded an retextured beret. What I need to do if it's not a real hat?

0

Wait, maybe I need to put the model id.

0

No it didn't worked.

0

Ok It worked! Thank you so much and have a nice day! Also can I put in my game your name and say that you helped me with scripting? (I will make a gui.)

0

Sure, if you want! :)

0

Oh and don't forget to accept my answer, gotta get them reps :P

0

Ok, now bye!

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