Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BodyVelocity works when I first join the game , when I move it stops working?


local plr = game.Players.LocalPlayer

repeat wait() until plr.Character and plr.Character.UpperTorso and plr.Character.HumanoidRootPart

local char = plr.Character
local animation = game:GetService("ReplicatedStorage"):WaitForChild("Animation1")
local torso = char.UpperTorso
print("I waited for it!")
local humroot = char.HumanoidRootPart

local Folder = Instance.new("Folder")
Folder.Name = plr.Name .."'s Stuff"
Folder.Parent = char



function onKeyPressQ(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		print("Q was pressed")
		local animTrack = char.Humanoid:LoadAnimation(animation)
		
		-- // Stuff
		
		local x = Instance.new("Part")
		x.Parent = Folder
		x.Size = Vector3.new(3, 3, 3)
		x.Shape = "Cylinder"
		x.Anchored = false
		x.CanCollide = false
		x.CFrame = humroot.CFrame * CFrame.new(0, 0, -5)
		
		
		local y = Instance.new("BodyVelocity")
		y.MaxForce = Vector3.new (math.huge,math.huge,math.huge)
		y.Velocity = humroot.CFrame.lookVector * 100
		y.P = math.huge
		y.Parent = x
		
		
		-- // Stuff		
		
		
		animTrack:Play()
	end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPressQ)

When I join the game and spam Q the part goes infinitely in that direction but, when I move the bodyvelocity stops working, any clue why?

Here's a gif to clarify: https://gyazo.com/00f27cc6ccd03904a9efd586965fd753

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.