Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When i was using context action service an error accord?

local Tool = script.Parent
local UserInputService = game:GetService("UserInputService")
local Camera = workspace.CurrentCamera
local ContextActionService = game:GetService("ContextActionService")
function MoveDown()
	local NewCFrame = Camera.CFrame * CFrame.new(5,0,0)
	Camera.CFrame = NewCFrame
end
	
Tool.Activated:Connect(function()
	Camera.CameraType= "Scriptable"
	Camera.CFrame = CFrame.new(Vector3.new(0,10,0),Vector3.new(0,0,0))
	ContextActionService:BindAction("MoveCamera1",MoveDown(),true,Enum.KeyCode.S)
	
end)

The error says Argument 2 missing or nil so i would assume that it thinks the funtion is nil i guess pls help

5 comments

0

CODE BLOCK pls

0

what is code block?

0

click the lua icon to format your code in lua (put your code in that block made of lines)

0

ok

0

i code blocked it refresh

2 answers

✓ Accepted answer

You're passing the return of MoveDown (nil). You need to pass the function literal. Just remove the parenthesis after MoveDown. Like so:

ContextActionService:BindAction("MoveCamera1", MoveDown, true, Enum.KeyCode.S)

Please remember to up vote and/or accept my answer, if it helped you.

1 comment

1

i cant upvote but ill accept your answer thx

It should be Enum.KeyCode.S, not "S".

6 comments

0

You can use s thats not the problem right now but ill use enum anyway

0

I don't think you can, I rechecked the api reference for CAS and it says to use Enum.

0

ok i changed it

0

it still doesnt work...

0

I'm looking at the code, is the line ContextActionService:BindAction("MoveCamera1", MoveDown(), true, Enum.KeyCode.S) ?

0

yes

This discussion is preserved as it was. New answers, comments, and votes are closed.