qwertluk
(gob23)
January 10, 2022, 7:00pm
#1
Hello, I’m trying to use object values to link/wire two objects together.
Well it works for the most part, but when someone deletes the power source the script errors and you cant wire to it again.
I have looked online.
“PoweredFrom” would be the object value.
Winbloo
(Winbloo)
January 10, 2022, 7:03pm
#2
Can’t you do if ObjectValue.Value then
?
qwertluk
(gob23)
January 10, 2022, 7:06pm
#3
gives me the same error at line 5
Winbloo
(Winbloo)
January 10, 2022, 7:09pm
#4
What’s the error?
And instead of running a loop, you should just connect an event to value.Changed
qwertluk
(gob23)
January 10, 2022, 7:10pm
#5
what is the “value” in this situation
Winbloo
(Winbloo)
January 10, 2022, 7:12pm
#6
Just an example, every value has a .Changed event. You can use that in your script for detecting changes
Winbloo
(Winbloo)
January 10, 2022, 7:15pm
#8
Well, I don’t really understand your code and what its supposed to do, can you provide the logic for it?
qwertluk
(gob23)
January 10, 2022, 7:16pm
#9
keep in mind that the value works until the power source is deleted then i get the error.
Winbloo
(Winbloo)
January 10, 2022, 7:19pm
#10
Well, I guess you can check if the power source exists with findfirstchild or whatever works
qwertluk
(gob23)
January 10, 2022, 7:23pm
#11
how the wiring logic works is there is a output bool-value in the power source in this case a switch. and a object value in the light block and every .5 seconds its changing the light depending on if the output value is true or false. Its just that when the switch is deleted then it no longer exists so it errors.
qwertluk
(gob23)
January 10, 2022, 7:24pm
#12
also findfirstchild wouldn’t work because its a placement game with many of the same blocks
NilFloat
(NilFloat)
January 10, 2022, 7:31pm
#13
Hello, so you would like to get rid of the error that appears once an instance is deleted? In this case, you can handle it with pcall .
1 Like
qwertluk
(gob23)
January 10, 2022, 7:50pm
#14
NilFloat:
pcall
k thxxxxxxxxxxxxxxxxxxxxxxxxxxx
local success,error = pcall(function()
local part = ObjectValue.Value
end)
if success then
—run object value exists code
end
1 Like
qwertluk
(gob23)
January 10, 2022, 9:17pm
#16
still producing the same error
NeoBuilds
(NeoBuilds)
January 10, 2022, 9:50pm
#17
It cant produce errors in pcall😑
qwertluk
(gob23)
January 10, 2022, 10:07pm
#18
well its still erroring. not the pcall the
NeoBuilds
(NeoBuilds)
January 10, 2022, 10:08pm
#19
Can you show me error, so I can tell what is wrong?
qwertluk
(gob23)
January 10, 2022, 10:11pm
#20
as I’ve said it’s just a error because the switch/output doesn’t exist anymore