Things are working in studio but not in-game

For some reason, my game’s dashing system loses the bodyvelocity faster in-game than the one in studio. Here are the videos:

See the difference?
I do not know if it is because the bodyvelocity is in the client’s script. But please help.

1 Like

One thing is that BodyVelocity is depracated, so it could be an issue with that.
Handling it in the client’s script is the right way to go, else it will feel sluggish for the client who is using the dash.
I’d recommend using the more modern LinearVelocity instead as that will continue to have support into the future.

If you really don’t want to use LinearVelocity, the only thing I can think of is that maybe you didn’t publish the place to Roblox and it’s using an older version.

1 Like

I figured it out, the studio perceives wait(0) as doing it all at once. I should have posted the script to help more.

Context:
The script was waiting 0 seconds to destroy the bodyvel but in the studio it worked fine, but in the game it didn’t wait and instantly destroyed the bodyvel, skipping all of the counts:

Corrected Script, the old one waited 0 seconds

if MoveDirection:Dot(Vector3.new(0,0,-1).Unit) > dotThreshold then
				script.CreateSound:FireServer(104671284040984)
				print("FrontDash")
				uvcd = true
				MainDash = true
				local thing = 100
				local DashFinished = false
				DashAnim:Play()
				while true do
					thing = thing - 1.5
					print(thing)
					local bodyvel = Instance.new("BodyVelocity")
					bodyvel.MaxForce = Vector3.new(1,1,1) * 100000000
					bodyvel.Velocity = script.Parent.HumanoidRootPart.CFrame.LookVector * thing
					bodyvel.Parent = script.Parent.HumanoidRootPart
					local hitbox = Instance.new("Part")
					hitbox.Size = Vector3.new(4,4,4)  -- Adjust size as needed
					hitbox.Position = script.Parent.HumanoidRootPart.Position + script.Parent.HumanoidRootPart.CFrame.LookVector * 2
					hitbox.Rotation = script.Parent.HumanoidRootPart.Rotation-- Spawn in front of the player
					hitbox.Anchored = true
					hitbox.CanCollide = false
					hitbox.Transparency = 0.9  -- Set transparency for the hitbox turn this to 1 to make it invisible
					hitbox.BrickColor = BrickColor.new("Bright red")
					hitbox.Parent = workspace
					hitbox.Material = Enum.Material.Neon
					local hitboxScan = workspace:GetPartsInPart(hitbox)

					for i, v in pairs(hitboxScan) do
						if v.Parent.Humanoid and v.Parent ~= script.Parent then
							script.CreateSound:FireServer(5835032207)
							script.CreateSound:FireServer(8389443538)
						DashAnim.TimePosition = 1
						script.RemoteEvent:FireServer(v,thing)
						DashFinished = true
						end
					end
					if thing <= 0 or DashFinished == true or script.Parent.Stunned == true then
						print("DashFinished")
						bodyvel:Destroy()
						hitbox:Destroy()
						break
					end
					task.wait(0.01)
					bodyvel:Destroy()
					hitbox:Destroy()
				end
				hum.WalkSpeed = 0
				hum.JumpPower = 0
				uvcd = false
				wait(0.4)
				hum.WalkSpeed = 16
				hum.JumpPower = 50
				wait(7.6)
				MainDash = false

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.