Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Script doesn't work at all but nothing shows in the output weird, is this a glitch/bug?

Asked by 3 years ago

This script doesn't work but nothing shows in the output so i'm completely lost right now. Can somebody help?

Script:

db = false

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid")then
        if db == false then
            db = true
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            local wood = game.ReplicatedStorage.Tools.Wood
            if wood.Parent == player.Backpack then
                wood:Destroy()
                player.leaderstats.Passes.Value = player.leaderstats.Passes.Value + 1
                script.Parent.BrickColor = BrickColor.new("Really red")
                wait(5)
                script.Parent.BrickColor = BrickColor.new("Medium stone grey")
                db = false
            end
        end
    end
end)
0
try putting print on some of the lines to check if the script is running Struggage 10 — 3y
0
I did try, doesn't work. It's like the script is disabled but it isn't disabled. :( Nitrolux200 62 — 3y
0
Do you have the object "Wood"? Also, when the tool is equipped, it goes into your player's character. It might not be detecting the humanoid and it might be detecting something else. Before line 4, put print("hit") squidiskool 208 — 3y
0
Also, what is the script supposed to do? squidiskool 208 — 3y
View all comments (2 more)
0
Script's supposed to get rid of your "wood" and give you 1 "pass" so like a sell system. I'm new to scripting so idk much Nitrolux200 62 — 3y
0
when i touch the part it print "hit" but does nothing else Nitrolux200 62 — 3y

1 answer

Log in to vote
0
Answered by
OhManXDXD 445 Moderation Voter
3 years ago
Edited 3 years ago

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.


db = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then if db == false then db = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) local wood = hit.Parent:FindFirstChild("Wood") -- find Wood in character if wood then wood:Destroy() player.leaderstats.Passes.Value = player.leaderstats.Passes.Value + 1 script.Parent.BrickColor = BrickColor.new("Really red") wait(5) script.Parent.BrickColor = BrickColor.new("Medium stone grey") db = false end end end end)
0
It doesn't work.. Nitrolux200 62 — 3y
0
Any errors? OhManXDXD 445 — 3y
0
Fixed OhManXDXD 445 — 3y
0
doesn't work still. Nitrolux200 62 — 3y
Ad

Answer this question