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

How to clone a tool from replicated storage to backpack with a dialog?

Asked by 2 years ago

So I'm making a little hangout place for me and my friends and I was thinking of making a bar with a dialog. The dialog works well but it doesn't give me the item. Here's the script I wrote. The script is right inside the DialogChoice.

local rootBeer = game.ReplicatedStorage.RootBeer

workspace.Dialog.DialogChoiceSelected:connect(function(player,choice)
    if choice.Name == "RootBeer" then
        local clone = rootBeer:Clone() -- Setting the clone to the variable "clone"
        clone.Parent = player.Backpack -- setting "clone"'s parent to player.Backpack
    end
end)

1 answer

Log in to vote
0
Answered by
Miniller 562 Moderation Voter
2 years ago

Hi! First of all it's kinda weird how you have the dialog directly in the workspace. It's usually a child of a part, like a character's head.

Second of all, you must use a LocalScript (or ModuleScript required by LocalScript) and you must put that LocalScript in either StarterPlayerScripts or StarterCharacterScripts. Since a localscript is client-side only, if you want everyone else to see the tool as well you will have to use a RemoteEvent. It's not complicated, all you have to do is add a RemoteEvent in ReplicatedStorage, fire it (with :FireServer()) and have a server-side script in ServerScriptService listen for the OnServerFired event. (You should definitely read the documentation though)

Ad

Answer this question