ContextActionService:SetPosition not working

Why is setposition not working? it literally change nothing in the positions, its still offset.

It only happen for those 2 buttons


this reload button works perfectly fine

here the 3 scripts for all of them

sprint:

local player = game.Players.LocalPlayer
local contextActionService = game:GetService("ContextActionService")
local RunToggle = true
contextActionService:BindAction("Run",function(name,state)
	if state == Enum.UserInputState.Begin then
		local char = player.Character
		if RunToggle then
			if char then
				char:WaitForChild("Humanoid").WalkSpeed = 22
			end
			RunToggle = false
		else
			RunToggle = true
			if char then
				char:WaitForChild("Humanoid").WalkSpeed = 16
			end		
		end		
	end
	return Enum.ContextActionResult.Pass
end,true,Enum.KeyCode.LeftShift,Enum.KeyCode.RightShift)
contextActionService:SetTitle("Run","Sprint")
contextActionService:SetPosition("Run", UDim2.new(0.3,0,0.2,0))

crouch

local player = {}
local input = {}
local animation = {}
crouch_animation = "rbxassetid://13145534892"
local players = game:GetService("Players")
local runservice = game:GetService("RunService")
local userinput = game:GetService("UserInputService")
local contextActionService = game:GetService("ContextActionService")


do -- player
	local players = game:GetService('Players')
	local PLAYER = players.LocalPlayer

	player = setmetatable({}, {__index = function(k)
		return rawget(player, k) or PLAYER:FindFirstChild(tostring(k))
	end})

	local function onCharacter(character)
		wait()
		player.character = character
		player.mouse = PLAYER:GetMouse()
		player.backpack = PLAYER:WaitForChild "Backpack"
		player.humanoid = player.character:WaitForChild "Humanoid"		
		player.torso = player.character:WaitForChild "Torso"
		player.alive = true
		script.crouch.AnimationId = crouch_animation

		repeat wait() until player.humanoid.Parent == player.character and player.character:IsDescendantOf(game)
		animation.crouch = player.humanoid:LoadAnimation(script:WaitForChild"crouch")
		input.stance = "stand"
		local onDied onDied = player.humanoid.Died:connect(function()
			player.alive = false
			onDied:disconnect()
			if animation.crouch then
				animation.crouch:Stop(.2)
			end
		end)
	end
	if PLAYER.Character then
		onCharacter(PLAYER.Character)
	end
	PLAYER.CharacterAdded:connect(onCharacter)
end

do -- input
	input.stance = "stand"
	local sprinting = false
	local default_right = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
	local default_left = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
	runservice.RenderStepped:connect(function()
		if animation.crouch then
			if animation.crouch.IsPlaying then
				animation.crouch:AdjustSpeed(Vector3.new(player.torso.Velocity.x, 0, player.torso.Velocity.z).magnitude/10)
			end
		end
	end)
	userinput.TextBoxFocused:connect(function()
		if sprinting then
			sprinting = false
			player.humanoid.WalkSpeed = 16
		end
	end)

contextActionService:BindAction("Crouch",function(name,state)
	if state == Enum.UserInputState.Begin then
		if input.stance == "crouch" then
			player.humanoid.HipHeight = 0
			player.humanoid.WalkSpeed = 16
			animation.crouch:Stop(.2)
			input.stance = "stand"
			print("stopping if crouching")
		else
			input.stance = "crouch"
			print(input.stance)
			player.humanoid.HipHeight = -1
			player.humanoid.WalkSpeed = 16 * 0.3
			animation.crouch:Play(.2)
			print("playing if standing")
		end
	end
	return Enum.ContextActionResult.Pass
end,true)
	contextActionService:SetPosition("Crouch", UDim2.new(0.3,0,0.4,0))
	contextActionService:SetTitle("Crouch","Crouch")
end

reload button that only setposition actually work

ContextActionService:BindAction("Reload",function(name,state)
			if state == Enum.UserInputState.Begin then
				self:reload()
			end
			return Enum.ContextActionResult.Pass
		end,true)
		ContextActionService:SetPosition("Reload", UDim2.new(0.3,0,0.16,0))
		ContextActionService:SetTitle("Reload","Reload")

cant put whole reload script because its over 970 line

2 Likes