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

Tool's parent not moving into Backpack?

So what I'm trying to do is make you able to choose ur breathing (some anime stuff):

https://gyazo.com/30636cba077e7c53d8ef65a3f0955261

For that I need to move as example Thunder from ReplicatedStorage into the LocalPlayers Backpack, but when I do that the tool does not work anymore, the model doesn't even show up anymore.

This is my code:

script.Parent.MouseButton1Click:Connect(function()
    local t = game.ReplicatedStorage.Thunder:Clone()
    t.Parent = game.Players.LocalPlayer.Backpack
    script.Parent.Parent.Parent.Enabled = false
end)

2 comments

0

You'd need a RemoteEvent as LocalScript's cannot clone tools into the player's backpack and make it useable.

0

Oh really? Thanks! I didn't know that.

1 answer

✓ Accepted answer

Hey there. Use this, and as youtubemaster said, use remotevents to clone:

PLACE BELOW INSIDE A SCRIPT WITHING ServerScriptService

game.ReplicatedStorage.GiveThunder.OnServerEvent:Connect(function(player)
	local t = game.ReplicatedStorage.Thunder:Clone()
	t.Parent = player.Backpack
end)

PLACE BELOW WITHIN A LOCALSCRIPT INSIDE OF THE TextButton

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.GiveThunder:FireServer(player)
    script.Parent.Parent.Parent.Enabled = false
end)

Make sure you add a RemoteEvent to "ReplicatedStorage" and call it GiveThunder

2 comments

0

Thank you so much! It worked!

0

Don't fire the server with ":FireServer(player)". Instead, just fire the server without any arguments. The player argument is automatic.

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