-
What do you want to achieve?
ContextActionSevice Buttons that shows the customizations i made -
What is the issue?
I made a few (6) buttons that have custom appearances, but when i test the buttons, those customizations do not appear. The buttons and their positions show correctly, but they dont show the images, transparency, etc. -
What solutions have you tried so far?
I tried re-arranging and fixing a few errors, but to no avail. I’ve checked the forum for any solutions, but i wasn’t able to find any posts that matches my problem
this is a mockup of the code i wrote:
local ContextActionService = game:GetService("ContextActionService")
local function MoveRight(actionName, inputState, inputObject)
if actionName == "MoveRight" then
if inputState == Enum.UserInputState.Begin then
print("MoveRight Functioning")
end
end
end
local function MoveLeft(actionName, inputState, inputObject)
if actionName == "MoveLeft" then
if inputState == Enum.UserInputState.Begin then
print("MoveLeft Functioning")
end
end
end
local function MoveUp(actionName, inputState, inputObject)
if actionName == "MoveUp" then
if inputState == Enum.UserInputState.Begin then
print("MoveUpLeft Functioning")
end
end
end
local function MoveDown(actionName, inputState, inputObject)
if actionName == "MoveDown" then
if inputState == Enum.UserInputState.Begin then
print("MoveDown Functioning")
end
end
end
local function ChangeView(actionName, inputState, inputObject)
if actionName == "ViewDownSights" then
if inputState == Enum.UserInputState.Begin then
print("ViewDownSights Functioning")
end
end
end
local function FireGun(actionName, inputState, inputObject)
if actionName == "FireGun" then
if inputState == Enum.UserInputState.Begin then
print("FireGun Functioning")
end
end
end
ContextActionService:BindAction("MoveRight", MoveRight, true, Enum.KeyCode.D)
ContextActionService:SetPosition("MoveRight", UDim2.new(-1.651, 0, 0.35, 0))
ContextActionService:BindAction("MoveLeft", MoveLeft, true, Enum.KeyCode.A)
ContextActionService:SetPosition("MoveLeft", UDim2.new(-2.151, 0, 0.35, 0))
ContextActionService:BindAction("MoveUp", MoveUp, true, Enum.KeyCode.W)
ContextActionService:SetPosition("MoveUp", UDim2.new(-1.901, 0, 0.166, 0))
ContextActionService:BindAction("MoveDown", MoveDown, true, Enum.KeyCode.S)
ContextActionService:SetPosition("MoveDown", UDim2.new(-1.901, 0, 0.512, 0))
ContextActionService:BindAction("ViewDownSights", ChangeView, true, Enum.Keycode.C)
ContextActionService:SetPosition("ViewDownSights", UDim2.new(0.531, 0, -0.05, 0))
ContextActionService:BindAction("FireGun", FireGun, true, Enum.KeyCode.F)
ContextActionService:SetPosition("FIreGun", UDim2.new(0.583, 0, -0.467, 0))
local MoveRight = ContextActionService:GetButton("MoveRight")
local MoveLeft = ContextActionService:GetButton("MoveLeft")
local MoveUp = ContextActionService:GetButton("MoveUp")
local MoveDown = ContextActionService:GetButton("MoveDown")
local ViewDownSights = ContextActionService:GetButton("ViewDownSights")
local FireGun = ContextActionService:GetButton("FireGun")
if MoveRight then
Instance.new("UIAspectRatioConstraint").Parent = MoveRight
game:GetService("RunService").RenderStepped:Connect(function()
MoveRight.Name = "RightButton"
MoveRight.Image = "rbxassetid://7809954579"
MoveRight.Size = UDim2.new(0.252, 0, 0.304, 0)
MoveRight.ImageTransparency = 0.45
end)
end
if MoveLeft then
Instance.new("UIAspectRatioConstraint").Parent = MoveLeft
game:GetService("RunService").RenderStepped:Connect(function()
MoveLeft.Name = "LeftButton"
MoveLeft.Image = "rbxassetid://7809954579"
MoveLeft.Size = UDim2.new(0.252, 0, 0.304, 0)
MoveLeft.ImageTransparency = 0.45
end)
end
if MoveUp then
Instance.new("UIAspectRatioConstraint").Parent = MoveUp
game:GetService("RunService").RenderStepped:Connect(function()
MoveUp.Name = "UpButton"
MoveUp.Image = "rbxassetid://7809954579"
MoveUp.Size = UDim2.new(0.252, 0, 0.304, 0)
MoveUp.ImageTransparency = 0.45
end)
end
if MoveDown then
Instance.new("UIAspectRatioConstraint").Parent = MoveDown
game:GetService("RunService").RenderStepped:Connect(function()
MoveDown.Name = "DownButton"
MoveDown.Image = "rbxassetid://7809954579"
MoveDown.Size = UDim2.new(0.252, 0, 0.304, 0)
MoveDown.ImageTransparency = 0.45
end)
end
if ViewDownSights then
Instance.new("UIAspectRatioConstraint").Parent = ViewDownSights
game:GetService("RunService").RenderStepped:Connect(function()
ViewDownSights.Name = "AimButton"
ViewDownSights.Image = "rbxassetid://7809955188"
ViewDownSights.Size = UDim2.new(0.339, 0, 0.362, 0)
ViewDownSights.ImageTransparency = 0.45
end)
end
if FireGun then
Instance.new("UIAspectRatioConstraint").Parent = FireGun
game:GetService("RunService").RenderStepped:Connect(function()
FireGun.Name = "FireButton"
FireGun.Image = "rbxassetid://7809954579"
FireGun.Size = UDim2.new(0.339, 0, 0.362, 0)
FireGun.ImageTransparency = 0.45
end)
end
please help!