I was attempting to make some code that detects movement on all platforms, wether it be virtual or physical joystick input, or keyboard. I got it working perfectly fine, but it randomly decided to stop detecting even after like 3 tests with the same results. Im genuinely confused on why it would do this, and wether its a studio glitch or something I did to somehow affect the way the code operated, because I didn’t change anything about it between the time I tested it working, and when I tested it to not work. To specify, the glitch transferred to the actual game on the Roblox app, so idk.
Here’s the script, there may be some unrelated stuff, but the detection is fully inside of this script (mainly within the first RenderStepped function).
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Control = require(Player.PlayerScripts.PlayerModule.ControlModule)
RunService.RenderStepped:Connect(function()
if script.Parent.InWater.Value == false then
local InputDirection = Control:GetMoveVector()
if InputDirection.Magnitude > 0 then
if InputDirection.Z < -0.5 and InputDirection.Z > -1 then
local X, Y, Z = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z
script.Parent.MoveForwards:FireServer(X, Y, Z) if game.SoundService.Swim2.Playing == false then game.SoundService.Swim2:Play() end
elseif InputDirection.Z > 0.5 and InputDirection.Z < 1 then
local X, Y, Z = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z
script.Parent.MoveBackwards:FireServer(X, Y, Z) if game.SoundService.Swim2.Playing == false then game.SoundService.Swim2:Play() end
end
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function(deltaTime: number)
if script.Parent.InWater.Value == true then
if script.Parent.Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
if game.SoundService.Swim3.Playing == false then game.SoundService.Swim3:Play() end
end
end
end)
The way I detect the movement works fine if I just do InputDirection == -1 or positive 1, but then its to precise to detect for mobile or console. I even tried testing on the previous version that was working, that for some reason stopped working too, which gives me even more of an inclination that this is a studio issue.