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 I can make 1 part be taken before another?(still needs help)

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

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

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)

3 comments

0

Where are the bricks located in regards to the script? And what are their names?

0

oh should I change the name name

0

the last end's a red line under it

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