Hello everyone. For some reason there is an extremely annoying error in my script that I don’t know how to fix without keeping the script neat and organized.
The following error message pops up saying “Attempt to connect failed: Passed value is not a function - Studio”
In case you’re wondering what the function is for, it’s for a door with a button that can be opened and closed by clicking on a button with a ClickDetector. It works normally, though I wanted to make it where other scripts can open the door by setting a bool value named “RequestClick”, which is parented inside of the script itself handling the door opening and closing. The RequestClick bool value is intended for giving the script that that handles door a signal to open or close it.
Example of what I meant:
local doorscript = workspace.Door.Script.RequestClick
doorscript.Value = true
The Script inside of the door should respond to the request click being set to true, so it makes it false and then opens or closes the door.
I thought of this because this was intended for a map in my game and thought I could have a script in a map that sets the value to true to make the door appear opened or closed as if a player has opened or closed it already, or perhaps for other stuff such as a door being opened by an entity. (Specifically, SCP-079 closing a door in front of a player to slow them down)
Specifically, the door is meant for an SCP game I’m working on. (if you know what an SCP is, though you don’t have to know about it)
Keep in mind I will only give a part of the code because I feel like someone could try to steal my code just for their own game.
Here is a part of the script (Code 1):
local ButtonRequest = script.RequestClick
ButtonRequest.Changed:Connect(ButtonRequestFunction)
function ButtonRequestFunction(prop)
if ButtonRequest.Value then
ButtonRequest.Value = false
Clicked()
end
end
NOTES ON PARTS OF THE CODE:
The Clicked() function is just a function that opens or closes the door. Don’t mind the Clicked() function since there are no errors with it.
The “prop” on the function was just me trying to get the property when I first started scripting it, but I left it there as an unused part and it doesn’t seem to affect the code whatsoever.
The error message says that it comes from Studio, which refers to Roblox Studio itself. I think this could be a Studio bug since it doesn’t redirect to a line part of the code.
Keep in mind that this code didn’t break my entire script, since the code can still allow the player to open and close the door, the problem is that setting the bool value “RequestClick” to true doesn’t open or close the door and it does nothing due to the error.
However, I found out that making the script like this (Code 2):
local ButtonRequest = script.RequestClick
ButtonRequest.Changed:Connect(function()
if ButtonRequest.Value then
ButtonRequest.Value = false
Clicked()
end
end)
The code has no issues, and it doesn’t throw an error. This is very strange since I can’t just simply put a function in the :Connect(functionnamehere) and instead I have to do something like :Connect(function() end) exclusively only for Changed events in order to get it to work.
This does let me open or close the door if I try setting the bool value “RequestClick” value to true.
Although it solves my problem, I had 2 other changed event functions.
One of them is suppose to be a changed function for another bool value inside called “079Locked”
This bool value is meant for a specific entity named SCP-079 forcefully locking the door, if a player attempts to open it makes a special type of sound effect and won’t budge the door open.
The other is the same but it’s called “079Open” and instead the said entity keeps the door open, making it unable to be closed by players.
Using the methods used in Code 2 it would make it look like a mess, which I don’t want.
Code 3 (this is not what I wanted to lay out my script like):
ButtonRequest.Changed:Connect(function()
--RequestClick function.
--Function request to open or close the door.
end)
ButtonRequest.Changed:Connect(function()
--079Locked function.
--SCP-079 will cause the door to be kept locked and the player cannot open it.
end)
ButtonRequest.Changed:Connect(function()
--079Open function.
--Just like 079Locked except it will make the door kept open and the player cannot close it.
end)
Code 4 (this is what I wanted my script to look like instead):
ButtonRequest.Changed:Connect(requesttoopenorclosethedoor)
ButtonRequest.Changed:Connect(the079lockedfunction)
ButtonRequest.Changed:Connect(the079openfunction)
--you get the idea the rest of the functions like function name() end are here
So what I’m saying is that I do not want my code to look like code 3, but instead code 4. Sadly, due to Roblox probably being a mess, code 4 just breaks by sending the error message like earlier.
Are there any ways to fix this bug? Or is this a bug Roblox probably hasn’t fixed a long time?
I did search up the Dev Forum and I found other Dev Forum posts such as this made by someone, they appear to have the same issue just like me. There were literally more than 2 posts posted by other people that had the same issue as me.
Judging by the other posts I found, the earliest one appeared in July 2021, which means that this must have been a bug for years.
THE EARLIEST POST I’VE FOUND
Sorry if there’s something wrong with this post, but this is my 2nd post and correct me if there’s an error on this post like the categories. I might just set this post as a bug report also.