Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When i was using context action service an error accord?

Asked by
adcd433 12
3 years ago
Edited 3 years ago
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

0
CODE BLOCK pls DuckyRobIox 280 — 3y
0
what is code block? adcd433 12 — 3y
0
click the lua icon to format your code in lua (put your code in that block made of lines) Pupppy44 671 — 3y
0
ok adcd433 12 — 3y
0
i code blocked it refresh adcd433 12 — 3y

2 answers

Log in to vote
0
Answered by
oreoollie 649 Moderation Voter
3 years ago
Edited 3 years ago

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
i cant upvote but ill accept your answer thx adcd433 12 — 3y
Ad
Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
3 years ago

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

0
You can use s thats not the problem right now but ill use enum anyway adcd433 12 — 3y
0
I don't think you can, I rechecked the api reference for CAS and it says to use Enum. Pupppy44 671 — 3y
0
ok i changed it adcd433 12 — 3y
0
it still doesnt work... adcd433 12 — 3y
View all comments (2 more)
0
I'm looking at the code, is the line ContextActionService:BindAction("MoveCamera1", MoveDown(), true, Enum.KeyCode.S) ? Pupppy44 671 — 3y
0
yes adcd433 12 — 3y

Answer this question