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

I assign g as the key but when i press other buttons the code still run help?

Asked by
Damo999 182
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

it might be a stupid error but every time i press a key my camera changes the problem is that i assigned g as the key and for some reason any button i press it runs the code and i'm not sure why here is the code.

01buttonPressed = false
02mouse = game.Players.LocalPlayer:GetMouse()
03 
04mouse.KeyDown:connect(function(key)
05    buttonPressed = true
06    if key == "g" then
07        end
08end)
09 
10    mouse.KeyUp:connect(function(key)
11    buttonPressed = false
12    if key == "g" then
13    end
14    while wait() do
15    if buttonPressed then
View all 29 lines...

1 answer

Log in to vote
1
Answered by 10 years ago

I see your problem. At lines 12-13, you have the function and then you immediately end it with an end. You should move that end to around line 28.

Ad

Answer this question