script.Parent.Touched:connect(function(Part) if Part.Parent:FindFirstChild("Humanoid") then local player=getPlayer(Part.Parent) game.ReplicatedStorage.Tool:clone().Parent=player.Backpack end end)
I wouldn't know what to use instead of 'getPlayer' for the third line of code as it says it is an unknown. I was attempting to create a script that would clone a tool into the player's backpack on touch of a specific brick.
You're looking for the GetPlayerFromCharacter
method of game.Players
:
script.Parent.Touched:connect(function(Part) if Part.Parent:FindFirstChild("Humanoid") then local player=game.Players:GetPlayerFromCharacter(Part.Parent) game.ReplicatedStorage.Tool:clone().Parent=player.Backpack end end)
Try using the GetPlayerFromCharacter method of Players
The script below should fix your issue:
script.Parent.Touched:connect(function(Part) if Part.Parent:FindFirstChild("Humanoid") then local player=game.Players:GetPlayerFromCharacter(Part.Parent) game.ReplicatedStorage.Tool:clone().Parent=player.Backpack end end)
If my answer helped you, accept and upvote it. If not, please tell me the error message in the comments below.