Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tocuhed function is supposed to run when to variables are equal, but it doesnt?

Asked by 6 years ago

I have been basically been making a game and I have this button thats only supposed to run if you own the property and if the person who touched the button owns the property. This is to keep others from pressing your button.

Heres the line of code that doesnt work.

local NotActivated = true

Button.Touched:Connect(function(TouchedPlayer)
    if NotActivated == true then
        if script.Parent.Parent.OwnerDoor.Owner.Value == TouchedPlayer.Parent then

Keep in mind this is just a small portion of the code, its mainly the important stuff.

The last line doesnt work and I dont know why. It seems fine to me.

Thank you for your time :) If you have question ask them.

0
Baka! .Touched on a `TextButton`? Are you joking?? arshad145 392 — 6y
0
Its not a text button. Its a part with a surface gui over it. Please when you are going to comment dont comment like youve got some high power or something. GottaHaveAFunTime 218 — 6y
0
Literally youve already got a rep for people not liking you, leave the forums. GottaHaveAFunTime 218 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You are referring to an instance as if it were a value, take a look at this line: if script.Parent.Parent.OwnerDoor.Owner.Value == TouchedPlayer.Parent See the mistake? You're telling the game to check if the value of the instace "Owner" is another instance. I don't know what your structure is, but if you have something inside the player who touches it, you'll do something like

if script.Parent.Parent.OwnerDoor.Owner.Value == TouchedPlayer.Parent.*Item*.*OptionalValue* then ...

So for example, say the value of "Owner" is a string, which is "OwnerOfThis", you'd put a string value inside the player that also has a string value that is "OwnerOfThis" and you'll check for that value with the code above, so it'll be something like:

if script.Parent.Parent.OwnerDoor.Owner.Value == TouchedPlayer.Parent.Verifier.Value then ...

Let me know if this helps, keep me updated.

0
Are you dumb? Its an `ObjectValue`. arshad145 392 — 6y
0
lay off of him. FlippinAwesomeCrew 62 — 6y
0
That may work let me try something. GottaHaveAFunTime 218 — 6y
0
I got it. I realized since it is looking for a StringValue, that being owner. That I had to say if it was equal to a string value. So I added .Name to TouchedPlayer.Parent. GottaHaveAFunTime 218 — 6y
Ad

Answer this question