You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
a script customizable of wire
put in on part and clone touching the first part
fire first script
when the script fired calls the other script for it’s touching his part and detect him
What is the issue? Include screenshots / videos if possible!
i wan’t to make a delay mode but
makes a loop.
and i put a debounce but anyways loop
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes but i no find nothing relationated
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function GetTouchingParts(v)
local t = workspace:GetPartBoundsInBox(v.CFrame,v.Size)
table.remove(t,1)
return t
end
function OnFired(...)
wait()
script.Parent.BrickColor = BrickColor.random()
end
function OnOtherFired(...)
return ...
end
local canfire = true -- NO CHANGE
script.Fire.Event:Connect(function(...)
if canfire then
local d = {...}
OnFired(unpack(d))
canfire = false
for i,v in pairs(GetTouchingParts(script.Parent)) do
if v:FindFirstChild(script.Name) then
v[script.Name].Fire:Fire(OnOtherFired(unpack(d)))
end
end
canfire = true
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Sorry, I’m not 100% sure what you’re trying to do. But looking at your “canfire” thing I see why it might not be working: you’re calling OnFired, which yields, before setting canfire to false. That means in the 1/30th of a second before OnFired resumes and returns, canfire will still be true. Try setting canfire = falsebefore calling OnFired or any other function that yields (i.e. calls “wait” or something like that).
1: grab a part
2: put the script on part
3: clone and put touching the first part
4: fire the first script
5: the other part script fired
6: if you put a code on the script before cloning how script.Parent.BrickColor = BrickColor.Random() then the other reacts
the problem is makes a loop when you puts more of 3 parts only when i put a wait/delay
My guess for how redstone works is that every “redstone tick”, each component determines what state it should transition to based on the surrounding components or its own internal state, or something external (like a pressure plate).
But it doesn’t actually change into the new state right away, because the surrounding components might need to access the “current” state and not the “future” state to calculate their own future state.
So each component must be processed twice:
Determine future state
Transition to future state
For example if you have a type of component that can connect to one other component, and every tick it changes color to match whatever component it’s connected to. If you put two of these together and color then red and green, you would expect them to swap colors every tick so that component A starts green, B starts red, and after 1 tick A is red, B is green, after 2 ticks A is green, B is red, etc.
If you allow components to just transition state straight away, A would turn red first, then B would see that A is red and become red (like it already is), and then A and B have the same color so no color changing happens.