trtman33
(trtman33)
September 28, 2023, 2:27pm
#1
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.
(the file Structure)
Any Help would be Appreciated!
EDIT:
Could this be a the start of a Solution?
1 Like
vovo2007
(vovo2007)
September 28, 2023, 2:33pm
#2
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
trtman33
(trtman33)
September 28, 2023, 2:41pm
#4
Also, How would I change the Value?
Edit: Should I use a Bool Value? instead of String?
trtman33
(trtman33)
September 28, 2023, 2:49pm
#6
I think I may have found a solution, but I am testing it first!
trtman33
(trtman33)
September 28, 2023, 2:59pm
#8
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
trtman33
(trtman33)
September 28, 2023, 3:05pm
#10
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!
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?
trtman33
(trtman33)
September 28, 2023, 3:09pm
#13
I think my playerPos value should be player.Character.Head.Position instead of
workspace.player.Head.Position
1 Like
trtman33
(trtman33)
September 28, 2023, 3:10pm
#14
Render Distance for a Water Animation!
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
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
trtman33
(trtman33)
September 28, 2023, 3:16pm
#18
yeah there is.
Maybe I shouldn’t watch Youtube Tutorials and instead come here.
thegreatdabb
(Dabbingsdevnow)
September 28, 2023, 3:17pm
#20
The magnitude will always be positive, a distance from zero can never be negative
He’s just getting the distance between the players position and the waters position, so that wouldn’t matter?