brick = script.Parent sword = game.Lighting:FindFirstChild("Sword") brick.Touched:connect(function (player) if player.Character.Humanoid then local give = sword:clone() give.Parent = player.Backpack end end)
This is a script that give you sword when you touch brick but when i step on the brick nothing happen can someone help ?
You have a space between the parenthasi and the player parameter in your Anonymous function.
Also the backpack isn't stored in the character, it's in the player. You have to use the GetPlayerFromCharacter method to get the player. Or put this in a localscript and use game.Players.LocalPlayer.Backpack
-Goulstem
You have to actually get the player from it's character by using the GetPlayerFromCharacter method in Players, so you can get to the player's backpack.
brick = script.Parent sword = game.Lighting:FindFirstChild("Sword") brick.Touched:connect(function(hit) --Removed the space, just to be safe. local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Tries to get the player with their character, if the player exists. if player then --If the player exists then clone the sword to their backpack. local give = sword:clone() give.Parent = player.Backpack end end)