How do you make a script whereas when the players humanoid function is walking a value increases? since i tried doing this with the input began function and it works but its not mobile supported, and i want to be supported for both devices, so how can i do this?
this is the code
local uis = game:GetService("UserInputService")
local walking = false
local stepswalked = 0
local player = game.Players.LocalPlayer
local points = player:WaitForChild("Points")
local multiplier = player:WaitForChild("PointsMultiplier").Value
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.W then
walking = true
while walking == true do
points.Value = (points.Value + 1) * multiplier
wait()
end
elseif input.KeyCode == Enum.KeyCode.S then
walking = true
while walking == true do
points.Value = (points.Value + 1) * multiplier
wait()
end
elseif input.KeyCode == Enum.KeyCode.D then
walking = true
while walking == true do
points.Value = (points.Value + 1) * multiplier
wait()
end
elseif input.KeyCode == Enum.KeyCode.A then
walking = true
while walking == true do
points.Value = (points.Value + 1) * multiplier
wait()
end
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.W then
walking = false
elseif input.KeyCode == Enum.KeyCode.S then
walking = false
elseif input.KeyCode == Enum.KeyCode.D then
walking = false
elseif input.KeyCode == Enum.KeyCode.A then
walking = false
end
end
end)