ContextActionService:GetButton returns table

The problem is on the title.
Here is Localscript with no other error.

local function actionHandler(actionName, InputState, InputObject)
	if actionName == "Sprint" then
		if InputState == Enum.UserInputState.Begin then
			humanoid.WalkSpeed = 35
			
		elseif InputState == Enum.UserInputState.End then
			humanoid.WalkSpeed = 20
			
		end
		return Enum.ContextActionResult.Pass
	end
end

--ダッシュ
cas:BindAction("Sprint", actionHandler, true, Enum.KeyCode.LeftShift)
cas:SetPosition("Sprint", UDim2.new(0.5,0,0,0))
cas:SetTitle("Sprint", "sprint")
cas:GetButton("Sprint").Size = UDim2(0.5, 0, 0.5, 0)  -- error : Players.Oceanblue857.PlayerScripts.GuiManager:53: attempt to call a table value

cas and humanoid are defined correctly in the top of script.

This mistake was shameful.

It’s just a typo, you forgot .new().

cas:GetButton("Sprint").Size = UDim2(0.5, 0, 0.5, 0)

should be

cas:GetButton("Sprint").Size = UDim2.fromScale(0.5, 0.5)

(or UDim2.new() like you intended)

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.