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

Lighting to Backpack script; help?

How do I make a script so that if a model is clicked, the same version of it that has been already put in "Lighting" is cloned into the player's backpack? So far I have this...

Weapon = Lighting.Musket
script.Parent.MouseClick:connect(function(ClickedPlayer)
    Weapon:clone().Parent = Player.Backpack
end)
script.Parent.MouseClick:connect

--You'd put this under ClickDetector.

1 answer

✓ Accepted answer

I'm not entirely certain, but I do not believe you can use Lighting to reference the service unless you've defined it as a variable, so make it Weapon = game.Lighting.Musket unless you have a variable set for Lighting.

Also, where it says Weapon:clone().Parent = Player.Backpack, there is a problem: you used ClickedPlayer as the parameter to MouseClick, but then you called Player. Change that to ClickedPlayer.

This is all I could find; I hope this works for you!

EDIT: If you have any other questions, check out the MouseClick page on the Wiki : http://wiki.roblox.com/index.php?title=MouseClick_(Event)

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