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

Key pressed problem?

Asked by
Paldi 109
10 years ago

I have a problem with my script i made for a flying vehicle, i want that when the player get on the seat, he can use Q and E to have more movement controls but it dont work and i dont get any errors..

ps: the "--mouse" section is working.

01function onTouched(hit)
02    if hit.Parent.Humanoid ~= nil then
03       local plr = hit.Parent.Name
04       local player = game.Players:FindFirstChild(plr)
05       local mouse = player:GetMouse()
06       local s = script.Parent.TurnSpeed/140
07       local clickQ = false
08       local clickE = false
09       local clickM = false
10 
11-- Q and E
12 
13    mouse.KeyDown:connect(function(key)
14        if key == "q" then
15            if clickQ == false then
View all 49 lines...

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

The mouse is only accessible from a localscript, localscripts only work if they are stored in something directed towards the client.

You need to look into RemoteEvents / RemoteFunctions

Sorry i can't give you a more straightforward answer, but doing so would mean me remaking your whole code.

Ad

Answer this question