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

Is there anyway that I can make 1 block be taken before another?

Asked by 6 years ago

This script gives me one coin when I touch it. I want to make another script that makes 1 part (part1) be taken after part2. is there a script for that? Mabe a wait until script.

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)

1 answer

Log in to vote
0
Answered by
D3LTA_Y 72
6 years ago

Try using a "Key":

-- it is a script inside workspace
-- I recommend you make the coin with CanCollide false.

local p = workspace.Coin
local p2 = workspace.Locked

p.Touched:Connect(function(plr) 


  if plr.Parent.Humanoid then -- to be sure if a player touched this.
      local Permission = Instance.new("BoolValue", plr.Parent) -- We can create a permission here.
      Permission.Name = "Permission"
      Permission.Value = true
      -- You Can Add your Coin Script here too
      p:Destroy()
    end         
end)



p2.Touched:Connect(function(plr)

    if plr.Parent.Permission and plr.Parent.Humanoid then -- to be sure if a player touched this
       print("You can get this part")
       p2:Destroy()
    end         
end)
0
what should I name the parts ootheboss 32 — 6y
0
whatever you want in the variables. D3LTA_Y 72 — 6y
Ad

Answer this question