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

Is there anyway I can make 1 part be taken before another?(still needs help)

Asked by 6 years ago
Edited 6 years ago

This script gives me one coin for the block. I want to make it where one block is on top of the other and the top one has to be taken before the Bottom one.

script.Parent.Touched:connect(function(part)
    if game.Players:findFirstChild(part.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Name)
        plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
    end
end)
local debounce = true
script.Parent.Touched:connect(function(part)
    if debounce then
        debounce = false
        if game.Players:findFirstChild(part.Parent.Name) then
            local plr = game.Players:findFirstChild(part.Parent.Name)
            plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value
+1
            script.Parent:destroy()
        end
    end
end)

2 answers

Log in to vote
0
Answered by
dirk2999 103
6 years ago

My first question is why do you have 2 touched functions? Combine them together.

And for your question, just put an if statement in,

if script.Parent:FindFirstChild("TopBrick") then
print("Get the top block!")
else
--Text to give money and destroy block
end
Ad
Log in to vote
0
Answered by 6 years ago

I tried this and this is the code I tried. Is it wrong? it didn't work.

if script.Parent:FindFirstChild("TopBrick") then
Print(hi)
else
    script.Parent.Touched:connect(function(part)
    if game.Players:findFirstChild(part.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Name)
        plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
    end
end)
local debounce = true
script.Parent.Touched:connect(function(part)
    if debounce then
        debounce = false
        if game.Players:findFirstChild(part.Parent.Name) then
            local plr = game.Players:findFirstChild(part.Parent.Name)
            plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value
+1
            script.Parent:destroy()
        end
    end
end)

0
Where are the bricks located in regards to the script? And what are their names? dirk2999 103 — 6y
0
oh should I change the name name ootheboss 32 — 6y
0
the last end's a red line under it ootheboss 32 — 6y

Answer this question