How do I stop this from hapening ill make a free model if you guy want to try its

I want to be able to not make the part that I’m using W, A, S, D to move cancolide is on true for the walls and the parts

robloxapp-20210220-1505187.wmv (2.5 MB)

I don’t know what to do and here is the script I know it wouldn’t help much but here

Lua here

local UIS = game:GetService(“UserInputService”)
local movepart = game.Workspace.movepart
local stopA = false
local stopW = false
local stopS = false
local stopD = false
– W
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.W then
stopW = false
while wait() do
if stopW == false then
movepart.Position = movepart.Position - Vector3.fromAxis(Enum.Axis.Z)
print(movepart.Position)
end
end
end
end)

UIS.InputEnded:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.W then
stopW = true
end
end)
– S

UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.S then
stopS = false
while wait() do
if stopS == false then
movepart.Position = movepart.Position + Vector3.fromAxis(Enum.Axis.Z)
print(movepart.Position)
end
end
end
end)

UIS.InputEnded:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.S then
stopS = true
end
end)

–A
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.A then
stopA = false
while wait() do
if stopA == false then
movepart.Position = movepart.Position - Vector3.fromAxis(Enum.Axis.X)
print(movepart.Position)
end
end
end
end)

UIS.InputEnded:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.A then
stopA = true
end
end)
– D

UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.D then
stopD = false
while wait() do
if stopD == false then
movepart.Position = movepart.Position + Vector3.fromAxis(Enum.Axis.X)
print(movepart.Position)
end
end
end
end)

UIS.InputEnded:Connect(function(input,isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.D then
stopD = true
end
end)

3 Likes

You can check if the distance that will be covered is greater than your max x or z axis then return end

2 Likes

use
‘’
``` lua here ``
`
"
when adding code so its not confusing

edit: example:

print('hi')

2 Likes

Back to the script…

What you could do is:

function getTouching(obj) --dirty hack
local touch=obj.Touched:connect(function()end)
local touching=touch:getTouchingParts()
touch:disconnect()
return touching
end

local UIS = game:GetService(“UserInputService”)
local movepart = game.Workspace.movepart
local currentMove
local studs=1 --speed

function move(dir)
currentMove=game:GetService('RunService').Heartbeat:connect(function()
if #getTouching(movepart)>0 then
currentMove:disconnect()
return
end
movepart.CFrame=movepart.CFrame*dir
end)
end

UIS.InputBegan:connect(function(io)
if io.KeyCode==Enum.KeyCode.W then
if currentMove then
currentMove:disconnect()
end
move(CFrame.new(0,0,-studs))
end
if io.KeyCode==Enum.KeyCode.S then
if currentMove then
currentMove:disconnect()
end
move(CFrame.new(0,0,studs))
end
-- you can add the rest
end)

idk if this works

2 Likes

thanks for the help ill try its but im already working on my own solution ill try yours after

1 Like

i forgot to add the anti collide
edit: added

its doesnt work but thanks for your help ive decided to leave its as its is

What’s the error? I can fix it pretty easilyy

Simple part mover (COLLIDES) - Pastebin.com should work

I did the stop moving part wrong! delete the move functions in the InputEnded

its doesnt collide and sorry for late response also keeps saying this

getTouchingParts is not a valid member of RBXScriptConnection - Client - LocalScript:3
17:06:03.446 Stack Begin - Studio
17:06:03.447 Script ‘Players.thexxsharkhunter.PlayerScripts.LocalScript’, Line 3 - function getTouching - Studio - LocalScript:3
17:06:03.447 Script ‘Players.thexxsharkhunter.PlayerScripts.LocalScript’, Line 15 - Studio - LocalScript:15
17:06:03.447 Stack End - Studio

but thanks for the help

my bad, search it up, i know it does exist.