If the player clicks the tool then i'm cloning it to the serverstorage and destoying the tool that the player clicked on. And then it will look like you picked it up. but it dosen't work, Help would be appreciated.
Inside Local script:
local Clone = game.ReplicatedStorage:FindFirstChild("BlueBerry1"):Clone() local Playerbackpack = game.Players.LocalPlayer.Backpack local Click = workspace.BlueBerry1.Part.ClickDetector local Bill = workspace.BlueBerry1.Part.BillboardGui ----------------------------------------------------------- Click.MouseClick:Connect(function() game.ReplicatedStorage.BlueBerry1:Clone() wait() Clone.Parent = Playerbackpack wait(0,5) end)
Ok, so first things first, you can't do this in a local script. A local script is client sided, meaning that it can only control things involving the player, so yes in a local script you can call game.Players.Localplayer.Backpack with ease a local script can't control a click detector like ClickDetector.MouseClick. So instead we use a regular script and the way we get in touch with the player is within the function:
local clicker = script.Parent.ClickDetector clicker.MouseClick:Connect(function(player)
When we say function(player) this player in the brackets is now the player that clicked this detector, so with this we can finish the script.
Script
local RepStorage = game:GetService("ReplicatedStorage") local clicker = script.Parent.ClickDetector clicker.MouseClick:Connect(function(player) local backpack = player:FindFirstChild("Backpack") local Clone = RepStorage.ClassicSword Clone.Parent = backpack wait(0.5) end)
Also you cloned the item twice in your script once out side of the function and once in the function.
And then finally when you want to get ReplicatedStorage the best method is to use: local replicatedStorage = game:GetService("ReplicatedStorage")