Some mobile questions

Hello, i was testing if mobile worked on my game after resizing most of the UIs with a rescale plugin. What i noticed and not sure if there is a way to fix is 3 things:

  1. My text on the left shows incomplete for some reason, but the proportions are correct just like in PC, any idea why is that?
  2. Is there any way to make the tools icons from the backpack smaller? They cover the stamina bar which is in the same position as on PC.

  1. How could i go about making this script, into a mobile button so sprint works there too as if players had pressed Shift. I also guess i have to create a local script in the same place i have my current Sprint script?
local player = game.Players.LocalPlayer
local character = player.Character

local UserInputService = game:GetService("UserInputService")

local stamina = 100
local running = false

stamina = math.clamp(stamina, 0, 100)

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		running = true
		character.Humanoid.WalkSpeed = 38
		while stamina > 0 and running do
			stamina = stamina - 1
			script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 1, 0), "Out", "Linear", 0)
			wait()
			if stamina == 0 then
				character.Humanoid.WalkSpeed = 16
			end
		end
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		running = false
		character.Humanoid.WalkSpeed = 16
		while stamina < 100 and not running do
			stamina = stamina + 1
			script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 1, 0), "Out", "Linear", 0)
			wait()
			if stamina == 0 then
				character.Humanoid.WalkSpeed = 16
			end
		end
	end
end)
1 Like

You should just be able to add a textbutton or imagebutton to that script and have it trigger the sprint for mobile.

2 Likes

You can also make a stamina bar go up and show the sprint button for mobile by using UserInputService.TouchEnabled to check if the player is on mobile or on Computer.

2 Likes

Thanks for both replies, managed to dig deeper into the api reference and other forum posts with the idea of making the GUI button and it works after some trial and error. Now only thing would be to fix number 1 and 2, if anyone has any solutions to those they would be greatly apreciated, cant find anything related to it so far on the internet and youtube.

For #1, that might happen if your text size is fixed (not scaled) and the text box is scaled. If its not that then idk.

1 Like

Thank you, i thought i had the check on for text scaled but i misslooked. That fixed that issue :slight_smile: