Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

2 comments

0

what should I name the parts

0

whatever you want in the variables.

This discussion is preserved as it was. New answers, comments, and votes are closed.