Hey! I’m having problem making the sprinting work using some advanced tweening using MouseEnter and MouseLeave and it doesn’t seems to be working, anyone can help? I would really appreciate it! (It also works on computer by the way)
Here is the footage:
https://i.gyazo.com/8e2e48f688250ed1f7f8bfecd6ed1070.mp4
Here is the script:
uis = game:GetService("UserInputService")
ismobile = uis.TouchEnabled
script.Parent.Parent.Enabled = ismobile
local btn = script.Parent
local Player = game:GetService('Players')
local sprinting = false
local isHovering = false
btn.MouseEnter:Connect(function()
isHovering = true
btn:TweenSize(UDim2.new(0.05, 0,0.097, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)
btn.MouseLeave:Connect(function()
isHovering = false
btn:TweenSize(UDim2.new(0.039, 0,0.086, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)
btn.MouseButton1Down:Connect(function()
btn:TweenSize(UDim2.new(0.028, 0, 0.075, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
local player = Player.LocalPlayer
if sprinting then
sprinting = false
btn.Image = "rbxassetid://6933361586"
player.Character.Humanoid.WalkSpeed = 16
else
sprinting = true
btn.Image = "rbxassetid://6933364478"
player.Character.Humanoid.WalkSpeed = 26
end
end)
btn.MouseButton1Up:Connect(function()
if not isHovering then
btn:TweenSize(UDim2.new(0.039, 0,0.086, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
else
btn:TweenSize(UDim2.new(0.05, 0,0.097, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end
end)
--MouseEnter: {0.05, 0},{0.097, 0}
--MouseLeave: {0.039, 0},{0.086, 0}
--MouseButton1Down: {0.028, 0},{0.075, 0}