I'm not really sure what to do. The code is as following:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local tool = game.ReplicatedStorage.Items("Vanilla Cakepop"):Clone()
tool.Parent = player.Backpack
end)
I'm not really sure what to do. The code is as following:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local tool = game.ReplicatedStorage.Items("Vanilla Cakepop"):Clone()
tool.Parent = player.Backpack
end)
Hey there Robloxgamer222781! I fixed your script, I'm going to provide it below. Before that though, I would like to let you know what was wrong with the script so it can help you next time!
First you can't have a space in the tool or the instance you're trying to find.
Here's a link on FindFirstChild, I highly recommend reading up on this. It's extremely useful!
https://developer.roblox.com/en-us/api-reference/function/Instance/FindFirstChild
Second I don't know what you're trying to call with "Items" but it doesn't work. FindFirstChild would be extremely useful for this if "Items" is the name of a model! Here's an example
local tool = game.ReplicatedStorage:FindFirstChild("ItemsModel").VanillaCakepop:Clone()
Other than that, everything was great! Here's your finished and fixed script. Don't forget to put a ClickDetector in the part (I'm assuming you already did just incase you didn't or someone else doesn't know how to)
This is a script inside of a part Put your tool in ReplicatedStorage inside of a model called ItemsModel
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local tool = game.ReplicatedStorage:FindFirstChild("Model").VanillaCakepop:Clone()
tool.Parent = player.Backpack
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Maybe try ["Vanilla Cakepop"] Instead of ("Vanilla Cakepop")
Hope that works!