How to prevent this from happening?

Game (prototype)

  1. What do you want to achieve? Keep it simple and clear!
    Prevent player from slowing down
  2. What is the issue? Include screenshots / videos if possible!
    robloxapp-20240816-1616265.wmv (1.4 MB)
    Player goes slower here and the clone gets out of the view
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Idk if theres solutions on dev hub

Note: game has no mobile support so u wont be able to replicate bug if u wanted

Script that makes the player move



local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")



local player = Players.LocalPlayer
local addSideMax = 1

local finalVector = Vector3.new(0, 0, -1)



--[[RunService.RenderStepped:Connect(function()
	if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
		local humanoidRootPart = player.Character.HumanoidRootPart
	end
end)]]

RunService:BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid:Move(finalVector, true)
		end
	end
end)


UserInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector + Vector3.new(-addSideMax,0,0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector + Vector3.new(addSideMax,0,0)
	end
end)

UserInputService.InputEnded:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector + Vector3.new(addSideMax,0,0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector + Vector3.new(-addSideMax,0,0)
	end
end)
3 Likes

A few changes…

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local addSideMax = 1
local moveSpeed = 16
local finalVector = Vector3.new(0, 0, -1)

RunService:BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
	if player.Character then
		local humanoid = player.Character:FindFirstChild("Humanoid")
		if humanoid then
			local magnitude = math.max(1, finalVector.Magnitude)
			humanoid:Move(finalVector.Unit * moveSpeed, true)
		end
	end
end)

UserInputService.InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector + Vector3.new(-addSideMax, 0, 0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector + Vector3.new(addSideMax, 0, 0)
	end
end)

UserInputService.InputEnded:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.A then
		finalVector = finalVector - Vector3.new(-addSideMax, 0, 0)
	elseif inputObject.KeyCode == Enum.KeyCode.D then
		finalVector = finalVector - Vector3.new(addSideMax, 0, 0)
	end
end)

This script is trying to set a constant move speed.

1 Like

Sorry, I forgot to comment/cut that out, I was working on something.

1 Like

Oh I put this in the wrong category, sorry! I think

The problem is collisions.

Issue:

1 Like

In the video It looks like the player walked into the wall. Are you in control of the player?
Yep, same video. walking into the wall … ??

Do u have a solution?
Tell me if u do

Hopefully u understand

Maybe … but, I do not understand what is happening, who is in control of what and what do you want it to really do.

The one that went into the wall is the player, when the player goes into the wall it slows down, and the clone (one on the right) gets out of view
I want the player to maintain speed

Why did the player walk into the wall?

I was testing if the player will slow down

If u dont know what im talking about join the game and go into the wall and u see the clone will slow down, how to stop that from happening? (clone doesnt have animation thats why it looks weird)

I still have no ideal what you are looking to happen here.
From the start what is suppose to be going on.

The player is supposed to not slow down when it goes in the wall

The clone is not slowing down at all. When you hit the wall it kind of looks like it is. But if you watch the ground and feet it really don’t look like it lost a step (slide in this case).

Not the clone, the player, the player slows down / slides

Because they hit a wall … is the wall to not have collision set? If so, that is part of the parts that make up the wall. Click on the wall part. Remove the check from collision.

Unless others help you here. Our conversation is getting a bit too large. You can PM me if you want to ask more questions. I will need: A full explanation of what you’re doing with this game?
What is it… How is really to be working… What have you tried to fix the problem and what is the problem. I have never seen your code before today. So, I don’t even know what it is you’re looking to do here. It looks like a race … Don’t hit the wall.

Just realized I can punish the player if they try to go in the wall (they fall through)

1 Like

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