Hello,
I’ve been working with magnitude recently to make a Leap Of Faith affect from Assassin Creed, so when I started writing the script I had to check the Z and the Y axis between the player and the hay stacks to make sure the player is above the hay stacks on a high spot, but this is when I ran into this problem magnitude is not working with 1 Axis nor all axis and I’m confused to why this is happening, any help is appreciated.
Hay stacks folder:
Error:
Script:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
repeat wait() until character:FindFirstChild("Humanoid")
local Count = 0
-- Checking if the player is running, crouching, etc
local function CheckBehavior()
local folder = character.Behavior
for i, v in ipairs(folder:GetChildren()) do
if v:IsA("BoolValue") then
if v.Value == false then
Count += 1
end
end
end
end
-- Loading Animations
local LoFS = character.Humanoid:LoadAnimation(script.LoFStart)
local LoFM = character.Humanoid:LoadAnimation(script.LoFMid)
local LoFF = character.Humanoid:LoadAnimation(script.LoFFinish)
UIS.InputBegan:Connect(function(inpt, UPE)
if UPE then return end
if inpt.KeyCode == Enum.KeyCode.F then
CheckBehavior()
if Count == 4 then
Count = 0
print("epic")
-- Looping through the hays and comparing positions
for i, v in ipairs(game.Workspace.Hays:GetChildren()) do
-- Getting the magnitude between the player and the hay stack
local UpMag = (player.Character.HumanoidRootPart.Position.Y - v.Position.Y)
local DisMag = (player.Character.HumanoidRootPart.Position.Z - v.Position.Z)
print(DisMag, " Non magnitude")
print(DisMag.magnitude, " with magnitude") -- Error here
print(UpMag.magnitude) -- Error here
if DisMag.magnitude <= 30 and UpMag.magnitude >= 20 then
print("Check")
local Root = player.Character.HumanoidRootPart
local Info = TweenInfo.new(3,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
character.Humanoid.Jump = true
-- Pulling the player to the hay stack
game:GetService("TweenService"):Create(Root, Info, {Position = v.Position}):Play()
print("Started")
end
end
end
end
end)