#Type Checker problem
1 messages · Page 1 of 1 (latest)
--!strict
-- @zyos73
-- 07/31/25
--Services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
--Variables
local player : any = Players.LocalPlayer
local oldMoveVector : Vector3 = Vector3.new(0,0,0)
--Modules
local playerModule = require(player.PlayerScripts.PlayerModule)
local controls = playerModule:GetControls()
--Settings
local TURN_ANIMATION : Animation = Instance.new("Animation")
TURN_ANIMATION.AnimationId = "rbxassetid://YOUR_TURN_ID" -- set ur animation id
local DEBOUNCE = false
local DEBOUNCE_TIME = .1 --set ur debounce time (0 if you want it removed)
function playTurnAnimation()
if DEBOUNCE then return end
DEBOUNCE = true
print("play")
--local humanoid = player.Character:WaitForChild("Humanoid")
--local animator = humanoid:FindFirstChildOfClass("Animator")
--local turnAnimationTrack = animator:LoadAnimation(TURN_ANIMATION)
--turnAnimationTrack:Play()
task.spawn(function()
task.wait(DEBOUNCE_TIME)
DEBOUNCE = false
end)
end
function compareVectors(vector1 : Vector3, vector2 : Vector3) : boolean
if (vector1.X == 0 and vector1.Z == 0) or (vector2.X == 0 and vector2.Z == 0) or (vector1.Y ~= 0) or (vector2.Y ~= 0) then return false end
if vector1.X + 2 == vector2.X then return true end
if vector1.X - 2 == vector2.X then return true end
if vector1.Z + 2 == vector2.Z then return true end
if vector1.Z - 2 == vector2.Z then return true end
end
RunService.Stepped:Connect(function()
local newMoveVector : Vector3 = controls:GetMoveVector()
if newMoveVector == Vector3.new(0,0,0) then return end
if newMoveVector == oldMoveVector then return end
if compareVectors(oldMoveVector, newMoveVector) then playTurnAnimation() end
oldMoveVector = newMoveVector
end)
Issue:
I coded a lot in lua but starting luau so maybe i'm wrong but it looks like luau doesnt understand what type .X and .Y should be
You can try using local variables to store the numbers and compare those variables, it should force them to be numbers
Smth like this:
function compareVectors(vector1: Vector3, vector2: Vector3): boolean
local x1, y1, z1 = vector1.X, vector1.Y, vector1.Z
local x2, y2, z2 = vector2.X, vector2.Y, vector2.Z
if (x1 == 0 and z1 == 0) or (x2 == 0 and z2 == 0) or (y1 ~= 0) or (y2 ~= 0) then
return false
end
if x1 + 2 == x2 then return true end
if x1 - 2 == x2 then return true end
if z1 + 2 == z2 then return true end
if z1 - 2 == z2 then return true end
return false
end
mmm
thats smart
thanks

im gonna start to cry
Why is Type Checker so complicated
mb
all good
it works
without setting the type
you mean removing : Vector3 ?
I started studio to check in a new script and i dont have the error you get in your screen
But if it works its good x)
nah I forgot that this technicly means that these variables have to be all given a number
and then we have the same problem that type checker cant convert these into numbers
Wait so the game still can't check if x1 + 2 == x2 then return true end etc ? or i dont understand properly ?
no it works now but the problem was that If I set the variables to numbers instantly they need a number and somehow the things here arent numbers like we figured out
ahhh okay i get it now sry
all good thanks for the help