Hello, I would like to know how can i make the “part” execute the ‘if’ only if it has been touched 1 time and then wait 3 seconds to be able to touch it again and execute the ‘if’
how can i do that?
LocalScript:
-- items
local it1 = script.Parent.item1
local it2 = script.Parent.item2
local it3 = script.Parent.item3
-- Touches parts
local tpart1 = game.Workspace.Touching1 -- RED
local tpart2 = game.Workspace.Touching2 -- BLUE
local tpart3 = game.Workspace.Touching3 -- GREEN
-- tables
local obj = {"x","xx","xxx"}
-- touches
tpart1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
table.insert(obj,1,it1)
print("touches red part")
wait(5)
it1.BackgroundColor3 = tpart1.Color
wait(5)
print(obj)
end
end)
tpart2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
table.insert(obj,1,it2)
print("touches blue part")
wait(5)
it2.BackgroundColor3 = tpart2.Color
wait(5)
print(obj)
end
end)
tpart3.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
table.insert(obj,1,it3)
print("touches green part")
wait(5)
it3.BackgroundColor3 = tpart3.Color
wait(5)
print(obj)
end
end)
Images
Project organization