What do I mean? I want to make it so I invoke the Remote Function whenever two bool values are true, and I don’t know how to do that.
So here’s how my Rock, Paper, Scissors script will work:
LocalScript:
Whenever two bool values are true it’s going to invoke the server
Script:
Will add gametags to the players that are stored in ReplicatedStorage(I mean their name)
GUI Script(LocalScript):
Whenever it finds the players gametag it makes the UI enabled only for that player using playergui.
Edit: I want to check them both in functions and not if, else statements as they check once and doesn’t check if it has changed or not.
Can’t you check if their values changed and then check the values?
Example
local bool1 = script.Parent.Bool1
local bool2 = script.Parent.Bool2
bool1.Changed:Conenct(function(newVal)
if newVal and bool2.Value then
--Do stuff
end
end)
bool2.Changed:Connect(function(newVal)
if bool1.Value and newVal then
--Do stuff
end
end
I would recommend making a function for both the code in those 2 events so you don’t duplicate code
If you’re referring to adding a function to do the code for both of them, I mean something like this
local bool1 = script.Parent.Bool1
local bool2 = script.Parent.Bool2
local function doSomething()
--Do stuff
end
bool1.Changed:Conenct(function(newVal)
if newVal and bool2.Value then
doSomething()
end
end)
bool2.Changed:Connect(function(newVal)
if bool1.Value and newVal then
doSomething()
end
end
For this, it would be better to use Changed and a separate function for checking. Example:
local bool1 = script.Parent.Bool1
local bool2 = script.Parent.Bool2
local remoteEvent = game:GetService(“ReplicatedStorage”).remoteEvent — Change this for wherever the event is located
function doSomething()
remoteEvent:FireServer()
end
function checkIfTrue()
if bool1.Value and bool2.Value then
doSomething()
end
end
bool1.Changed:Connect(checkIfTrue)
bool2.changed:Connect(checkIfTrue)
I mean they both do the same thing, check if a value is changed in a BaseValue. The only thing that you did that I didn’t was a function to reduce repetition for the condition checking. I just used Changed since I’m used to it
Actually, your won’t work. Changed passes the property that was changed as a parameter; you think it will pass the new value. Also, .Changed fires when ANY property is changed. Whether that be name, parent, etc. Read more here: Instance | Roblox Creator Documentation
Mine is more efficient, also you misunderstand what parameters are passed through. For example, you think it will pass true or false, when it actually passes “Parent”, “Transparency”, “Value”, etc.
Is there anything else you need help on, or was that it? If that was it, then go ahead and mark a post as an answer so future people know it was solved. If you need help with remote events, comment here.
Also it is not unnecessary. There is no performance differences. And the other values may change on accident. But non of this matters because of the link above.
That is correct for the most part. The only difference is that .Changed returns the new value of the BaseValue as a parameter but GetPropertyChangedSignal doesn’t. So both have their use cases depending on what is needed, but generally .Changed is better imo cause it’s simpler
Oh i see, sorry i was a bit confused, anyways, i mostly consider a good practice to use :GetPropertyChangedSignal() in objects that arent values due to the sake of simplicity (.Changed) and debugging, due i prefer getting the error for accidentally calling the value, but now that i can think it, i can just print whatever has been changed too. Choice is left to the developer