Please help player variable problems

Hi. I want to make raycast hit player with Player variable A,
and I want to make A and I interact with each other.
Below are the things I want.

If I press the primary button on the person I’m looking at,
that person becomes player varible A.
And if A held a ‘hi’ button in 10 seconds, A and I become player variable B of each other.

If A does not held a ‘hi’ button in 10 seconds, or does held a ‘crouch’ button,
player variable A disappears.

C and I break up if I try to <1.> someone else when I have C.

If I press the interact button within 2 meter of all player variable A people, the small message pops up to player variable A.

Hey, how you inform other player that you added him to your A so he knows that it is a time to hold ‘Hi’ button (what a button is that? just binded?)
What is C in your story?
Do you mean ‘Event Player.A’ is an array, am I right?


More info about me and my game mods you can find here.
Feel free to comment my ideas.

condition:
- is button held(event player, primary fire) == true

action:
- event player.A = ray cast hit player(eye position(event player), eye position(event player) + facing direction of(event player) * 100, ...)
- *2
- *1
*1:
- event player.Z = 0
- while(event player.A != null && event player.Z < 10 && not(is button held(event player.A, crouch)))
- wait(0.5, ignore condition)
- event player.Z += 0.5
- if(is button held(event player.A, "the hi button, whatever that is"))
- event player.B = event player.A
- event player.B.B = event player
- abort
- end
- end
- event player.A = null

I suppose you are talking about B here? In this case:

*2:
- if(event player.B != null && event player.A != null)
- event player.B.B = null
- event player.B = null
- end

This can be problematic with the code I have posted here, because the “waiting for input while-loop” blocks the rule from retriggering. To solve this you can set a variable D (or whatever) of the target to event player (event player.A.D = event player) and in another rule you check for event player.D != null and in the action list you do the while-loop thing (keep in mind that you are operating on the target now, so replace the “event player” with “event player.D” and “event player.A” with " event player").
This means that a player can send multiple friend requests but only receive one at a time (you should add a if(event player.A.D == null) action before setting D).
Then you just need to replace the simple setting of A to “ray cast hit player” or “null” by some array management.

1 Like