Help, I have this error that doesn't mean ANYTHING to me. So I have this part that when it ontouched, it is supposed to clone the tool and put it inside the backpack. It doesn't clone it and it just moves the tool instead. Can anybody tell me what is going on?
01 | local tool = game.ServerStorage.TestTool --Change TestTool to whatever you want |
02 | local inventory = tool:Clone() |
03 |
04 | function onTouched(hit) |
05 | local player = game.Players:GetPlayerFromCharacter()(hit.Parent) |
06 | if player:FindFirstChild( "Backpack" ) then |
07 | inventory.Parent = player.Backpack |
08 | end |
09 | end |
10 | script.Parent.Touched:connect(onTouched) |
There are a few bugs with ur script but ill give u the fixed script and explain them
01 | -- Also always put gears that need to be cloned in replicatedStorage as that is the storage ment for cloning not serverstorage |
02 |
03 |
04 | function onTouched(hit) |
05 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- u did brackets wrong |
06 | if player then -- just check if its a player no need to check the backpack |
07 | local tool = game.ReplicatedStorage.TestTool:Clone() -- clone it here or else itll only clone once globally and only 1 person can get the tool |
08 | tool.Parent = player:WaitForChild( "Backpack" ) -- use waitforchild here |
09 | end |
10 | end |
11 | script.Parent.Touched:connect(onTouched) |
Hope this helped u explain all the bugs with ur script