My script has a blue underline under tools. The script is giving me one sand with tools when you should get two. Can this be fixed?

script.Parent.Touched:connect(function(part)
    if part.Parent:IsA("Tool") and game.Players:FindFirstChild(part.Parent.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Parent.Name)
        wait(1)
		plr.leaderstats.Sand.Value = plr.leaderstats.Sand.Value + 1
		script.Parent:Destroy()
	end
end)
script.Parent.Touched:connect(function(part)
    if part.Parent:IsA("Tools") and game.Players:FindFirstChild(part.Parent.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Parent.Name)
        wait(.1)
		plr.leaderstats.Sand.Value = plr.leaderstats.Sand.Value + 2
		script.Parent:Destroy()
    end
end)

4 comments

0

"Tools" don't exist, this may be the name

0

not the name I changed it to hi still not working

0

I'm having a tough time understanding what you are asking. The function IsA takes in a class name and tools is not one of them. Are you trying to get the name? In that case don't use a function, but instead the equality test operator (==) and compare the name to your name.

0

I'm confused too...