Hello, im trying to resize and position the button that ContextActionService made for the Slash Button, but it returns this error in the output.
Error:
13:14:08.380 Workspace.PlayerName.LocalScript:45: attempt to index nil with ‘Size’ - Client - LocalScript:45
13:14:08.381 Stack Begin - Studio
13:14:08.381 Script ‘Workspace.PlayerName.LocalScript’, Line 45 - Studio - LocalScript:45
13:14:08.381 Stack End
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CAS = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local Backpack = player:WaitForChild("Backpack")
local Tool = Backpack:WaitForChild("ClassicSword")
local animation = ReplicatedStorage.Animations:WaitForChild("Slash")
local slashTrack = humanoid.Animator:LoadAnimation(animation)
local debounce = false
local function playAnimation()
debounce = true
slashTrack:Play()
humanoid:EquipTool(Tool)
slashTrack.Ended:Connect(function()
humanoid:UnequipTools(Tool)
end)
task.delay(35, function()
debounce = false
end)
end
local function onSlash(actionName, inputState)
if actionName == "Slash" and inputState == Enum.UserInputState.End and not debounce then
playAnimation()
end
end
if debounce then
CAS:UnbindAction("Slash")
elseif not debounce then
CAS:BindAction("Slash", onSlash, true, Enum.KeyCode.Q)
end
local slashButton = CAS:GetButton("Slash")
slashButton.Size = UDim2.new(50, 50, 0, 0)
slashButton.Position = UDim2.new(50, 50, 0, 0)
Does anyone know what’s happening?