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

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

Asked by
asgppl 5
6 years ago
Edited 6 years ago

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

0
I'm waiting for answers... asgppl 5 — 6y
0
People! Dont be scared! I'm making a game and I want to know how to make that dialog hat giver!!! asgppl 5 — 6y
0
People will answer your post eventually, dont post comments for no reason. EnderGamer358 79 — 6y
0
For no reason? WHAT THE ***? For no reason? Then why nobody is answering me huh? asgppl 5 — 6y
View all comments (2 more)
0
1 hour later... Still waiting for answers... asgppl 5 — 6y
0
finally someone answered me! Thank you MRbraveDragon! asgppl 5 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
Ok im going to test that in roblox studio. asgppl 5 — 6y
0
Sorry about the unnecessary print. I was using it for debugging MRbraveDragon 374 — 6y
0
Ok now question. Can I put that script inside Dialog Choice? asgppl 5 — 6y
0
ok nevermind I noticed now that you said that. asgppl 5 — 6y
View all comments (11 more)
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 MRbraveDragon 374 — 6y
0
OMG It worked! Thank you so much!!! :D asgppl 5 — 6y
0
No problem! MRbraveDragon 374 — 6y
0
Ok, but I normally created the script inside "Dialog" not "DialogChoice". asgppl 5 — 6y
0
Wait I noticed that I also maded an retextured beret. What I need to do if it's not a real hat? asgppl 5 — 6y
0
Wait, maybe I need to put the model id. asgppl 5 — 6y
0
No it didn't worked. asgppl 5 — 6y
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.) asgppl 5 — 6y
0
Sure, if you want! :) MRbraveDragon 374 — 6y
0
Oh and don't forget to accept my answer, gotta get them reps :P MRbraveDragon 374 — 6y
0
Ok, now bye! asgppl 5 — 6y
Ad

Answer this question