I have a block that has a fire animation, I want the block to move so that the fire moves with it. I want it to move from -81.5, 39551.812, 113 to 174.3, 39551.812, 113, then moves back to -81.5, 39551.812, 113 and so on repeat.
Here is my script so far:
local pos = script.Parent.Position local fireblock = script.Parent if pos < Vector3(174.3, 39551.812, 113) then fireblock.Position = pos + Vector3.new(1,0,0) end elseif pos > (174.3, 39551.812, 113) and pos > (-81.5, 39551.812, 113) then fireblock.Position = pos - Vector3.new(1,0,0) end)
It doesnt make sense but I think its fine except I have to change somethings. o what I am asking for is if anyone can see what I did wrong in the script?
Any help would be appreciated!
You can't compare two vectors using the greater than (>) and less than (<) operators (including these operators' counterparts that also checks for an equality): it's impractical and will result in an error. The best you can do is check each vectors' components using the aforementioned operators.
Your if statements also do not obey the language's syntax: the end
is supposed to be after the last condition check in a line of if, elseif's / else, not after every condition
if pos.x < 174.3 and pos.y < 39551.812 and pos.z < 113 then fireblock.Position = pos + Vector3.new(1) elseif (pos.x > 174.3 and pos.y > 39555.812 and pos.z > 113) and (pos.x > -81.5 and pos.y > 395551.812 and pos.z > 113) then fireblock.Position = pos - Vector3.new(1) end
In the code, notice I didn't write the entire Vector3.new(1)
. This is because if you don't pass anything for the other parameters (values you put between a function's paranthesis when calling), they will default to 0 for the Vector3.new()
function