- What do you want to achieve? Keep it simple and clear!
Im trying to make a local script that will stop the players from bumping into the walls.
- What is the issue? Include screenshots / videos if possible!
well it doesn,t working.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes i did look for the solutions and i tried it
-- Place this script inside the character or a LocalScript inside the StarterPlayerScripts
local character = script.Parent -- Assuming this script is placed inside the character
-- Function to calculate velocity magnitude
local function getVelocityMagnitude()
local HumanoidRootPart = character:FindFirstChildOfClass("HumanoidRootPart")
if HumanoidRootPart then
local velocity = HumanoidRootPart.Velocity
return velocity.magnitude
end
return 0
end
-- Function to stop animations if velocity is too low
local function stopAnimations()
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local velocityMagnitude = getVelocityMagnitude()
if velocityMagnitude < 2 then -- Adjust this threshold as needed
humanoid:Move(Vector3.new()) -- Stop movement
humanoid.AnimationController:StopAllAnimations() -- Stop all animations
end
end
end
-- Connect the function to the Heartbeat event to continuously check velocity
game:GetService("RunService").Heartbeat:Connect(stopAnimations)
im kinda new at developing so i think there is some fault in the script