This script doesn't work but nothing shows in the output so i'm completely lost right now. Can somebody help?
Script:
01 | db = false |
02 |
03 | script.Parent.Touched:Connect( function (hit) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
05 | if db = = false then |
06 | db = true |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | local wood = game.ReplicatedStorage.Tools.Wood |
09 | if wood.Parent = = player.Backpack then |
10 | wood:Destroy() |
11 | player.leaderstats.Passes.Value = player.leaderstats.Passes.Value + 1 |
12 | script.Parent.BrickColor = BrickColor.new( "Really red" ) |
13 | wait( 5 ) |
14 | script.Parent.BrickColor = BrickColor.new( "Medium stone grey" ) |
15 | db = false |
16 | end |
17 | end |
18 | end |
19 | end ) |
At line 8 you define Wood as a child of Tools in ReplicatedStorage, so line 9 would end because the Parent is not Player.Backpack.
Instead try to find a tool in Player.Backpack named “Wood”
Edit: I realized that when you equip a tool it parents itself to the character, sorry.
01 | db = false |
02 |
03 | script.Parent.Touched:Connect( function (hit) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
05 | if db = = false then |
06 | db = true |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | local wood = hit.Parent:FindFirstChild( "Wood" ) -- find Wood in character |
09 | if wood then |
10 | wood:Destroy() |
11 | player.leaderstats.Passes.Value = player.leaderstats.Passes.Value + 1 |
12 | script.Parent.BrickColor = BrickColor.new( "Really red" ) |
13 | wait( 5 ) |
14 | script.Parent.BrickColor = BrickColor.new( "Medium stone grey" ) |
15 | db = false |
16 | end |
17 | end |
18 | end |
19 | end ) |