Help Me With Wiring System

You can write your topic however you want, but you need to answer these questions:

  1. 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

  1. 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

  1. 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.

2 Likes

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 = false before calling OnFired or any other function that yields (i.e. calls “wait” or something like that).

can you explain what you are trying to do more cleary

oh yes i tryed that but not runs

a script to make a input/output part

example:

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

1 Like

there is a video

errors: {
robloxapp-20211222-1208228.wmv (247.6 KB)
this are more rare:
robloxapp-20211222-1209211.wmv (3.4 MB)

}

normal:
robloxapp-20211222-1207225.wmv (60.0 KB)

1 Like

How do you want it to behave? Are you thinking of something like redstone from Minecraft?

hmm yes

but a misc of redstone and repeter

1 Like

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:

  1. Determine future state
  2. 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.

when i’m test with spawn looks bad

and i no undestand for complete for you

you can put it on code?
or say what i need to change to solve it