ContextActionService Button Tablet Position

OK, I’ll explain this
so i have a problem in Button for Tablet, where Button Position and Size is Very different when i try it on Tablet. but when i try it on Phone it is very normal Button Size and Position but. when i try it on Tablet Size and Position is very different so… is there any solution for this problem??

Phone
image

Tablet
image

Code

local ContextActionService = game:GetService("ContextActionService")
ContextActionService:BindAction("sprint", OnInput, true,Enum.KeyCode.LeftShift)
ContextActionService:SetImage("sprint", "rbxassetid://1114393432")

local actionButton: ImageButton = ContextActionService:GetButton("sprint")

if actionButton then
	actionButton.ImageColor3 = Color3.fromRGB(255,255,255)
	actionButton.Position = UDim2.new(1,-81,1,-170)
	actionButton.Size = UDim2.fromOffset(70,70)
	actionButton.ImageTransparency = 1

	local notpress = "rbxassetid://8618269848"
	local press = "rbxassetid://14112658774"

	local ButtonFAKE = Instance.new("ImageLabel")
	ButtonFAKE .Parent = actionButton
	ButtonFAKE .BackgroundTransparency = 1
	ButtonFAKE .Size = UDim2.fromScale(1, 1)
	ButtonFAKE .ScaleType = Enum.ScaleType.Fit
	ButtonFAKE .Image = notpress

	actionButton:GetPropertyChangedSignal("Image"):Connect(function()
		if actionButton.Image == "https://www.roblox.com/asset/?id=97166444" then
			ButtonFAKE .Image = notpress
		else
			ButtonFAKE .Image = press
		end
	end)
end

Try using scale instead of offset

2 Likes

I’m back. Sorry for the late reply. Okay, I’ll give it a try.

change i have tried it but failed :frowning_with_open_mouth:

Have you tied zeroing out offset in the gui properties and using scale instead?

oh yeah i forgot hehehe sorry :sweat_smile:

yeah it’s working thanks Dude for your help :grinning:

UDim2.fromScale(0.221, 0.65)