Hello
-
What do you want to achieve? I would like a linked mobile button to the stamina
-
What is the issue? I dont know how to link them
-
What solutions have you tried so far? I looked for tutorials, I couldnt find any good ones
--Buttonscript
local contextActionService = game:GetService("ContextActionService")
local playerName = script.Parent.Parent.Name
local sprintValue = Instance.new("BoolValue")
sprintValue.Parent = script
local sprint = sprintValue.Value
function onButtonPress()
if sprint == true then
sprint = false
--game.Workspace[""..playerName..""].Humanoid.WalkSpeed = 14
else
sprint = true
--game.Workspace[""..playerName..""].Humanoid.WalkSpeed = 28
end
end
local mobilebutton = contextActionService:BindAction("SprintButton",onButtonPress,true,"Sprint")
contextActionService:SetPosition("SprintButton",UDim2.new(0.72,-25,0.20,-25))
contextActionService:SetImage("SprintButton","rbxassetid://2572666627")
-- Staminascript
local UIS = game:GetService('UserInputService')
local Bar = script.Parent:WaitForChild('Background'):WaitForChild('Bar')
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 30
local power = 10
local sprinting = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character
--= FunçÔes =--
UIS.InputBegan:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.Q and gameProcessed == false then
character.Humanoid.WalkSpeed = NewWalkSpeed
sprinting = true
while power > 0 and sprinting do
power = power - .1
Bar:TweenSize(UDim2.new(power / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
UIS.InputEnded:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.Q and gameProcessed == false then
character.Humanoid.WalkSpeed = NormalWalkSpeed
sprinting = false
while power < 10 and not sprinting do
power = power + .03
Bar:TweenSize(UDim2.new(power / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
Anything would help, except for something unhelpful
Thanks for reading