Help with Scripting Argument

Hello! I am attempting to code a script for a Animated Water I have, that makes the animation only play whenever the player is near it for optimization.

I am going to take the Position of the Water, then Take the position of the player,

and Subtract the Water from the Player position.

and depending on the distance, it will change a value from “true” to “false”

and the animation will only play if the value is “true”.

but I need help with the Argument There.

image
(the file Structure)

Any Help would be Appreciated! :slight_smile:

EDIT:
image
Could this be a the start of a Solution?

1 Like

You should do “if value then” or “if value == true then”

That should fix it’s let me know if you got more issues.

3 Likes

I Will Try That! :slight_smile:

I appreciate the help!

Also, How would I change the Value?

Edit: Should I use a Bool Value? instead of String?

I think I may have found a solution, but I am testing it first!

This is the New Version, but it still doesn’t work.

the output.

Should the RunContext be Client, Server, or Legacy?

You should do local value = script.Value and

if position > 15 then
value.Value = true
print("true")
else
value.Value = false
print("false")
end

It should stay the same, do not change RunContext ever, only very rare cases are required to change (by the way default is legacy)

1 Like

Now, there is only 1 issue for me to fix. and it’s the Player Position part.

Which i think i have a solution for! :slight_smile:

Well first of all the position is a vector3 so what you would need to do is

local position = (position 1 - position 2).Magnitude

Do

local character = player.Character or player.CharacterAdded:Wait()
local playerPos = character.Head.Position

Can you tell what will you use playerPos and waterPos for?

I think my playerPos value should be player.Character.Head.Position instead of

workspace.player.Head.Position

1 Like

Render Distance for a Water Animation! :sunglasses:

yes, as I said.

vector3’s minus vector3’s still equal to vector3’s.

with that in mind You HAVE to do .Magnitude to turn it into a number because > wont work on A whole vector3

1 Like

image

I cant remeber if the order matters but i think player pos would come first also I dont know if thats just what it looks like but It looks like theres a space inbetween the .Magnitude and vector3

yeah there is.

Maybe I shouldn’t watch Youtube Tutorials and instead come here. :sweat_smile:

So that Fixed it?

(char limitt 2131233)

The magnitude will always be positive, a distance from zero can never be negative

lemme check.

(CHARCHARCHARRRRSSS)

He’s just getting the distance between the players position and the waters position, so that wouldn’t matter?