Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Magnitude with HumanoidRootPart isn't working ?

Asked by 3 years ago
Edited 3 years ago

The script is located in game.StarterGui

The script is a "LocalScript"

-- Variables

local distPart = game.Workspace.distPart
local humRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")



if (humRootPart - distPart).magnitude < 15 then

    print("The Player Is In Range Of The Object!")

end

Here's the error that i'm getting : Players.ZOOP1015.PlayerGui.LocalScript:8: attempt to perform arithmetic (sub) on Instance

0
I think you need to define Position aswell.Like (humRootPart.Position - distPart.Position).Magnitude Spjureeedd 385 — 3y
0
Woah, that was a silly mistake that i did, thanks for the answer! How do i accept your answer on this website exactly, it doens't give me the option to do so. ZOOP1015 44 — 3y
0
Yeah you can't accept a comment as an answer Spjureeedd 385 — 3y

1 answer

Log in to vote
0
Answered by
Borrahh 265 Moderation Voter
3 years ago

Basically, You You need to check for the Positions of the both, that's how you use Position. To get the Vector3 Values eg of humRootPart and the ****distPart****

-- Variables

local distPart = game.Workspace.distPart
local humRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")



if (humRootPart.Position - distPart.Position).magnitude < 15 then

    print("The Player Is In Range Of The Object!")

end
Ad

Answer this question