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

How to detect when a player presses a button while inside of a seat?

Asked by 3 years ago

Hello, I am trying to add nitro button to my car but i can't get the players mouse for some reason this is what I have right now:

local character = script.Parent.DriveSeat.Occupant
local player = game.Players:GetPlayerFromCharacter(character.Parent)
local mouse = player:GetMouse()

script.Parent.DriveSeat.Changed:Connect(function(prop)
    if prop == ("Occupant") then
        character = script.Parent.DriveSeat.Occupant
        player = game.Players:GetPlayerFromCharacter(character.Parent)
        mouse = player:GetMouse()       
    end
end)

if mouse then
    mouse.KeyDown:connect(function(key)
        if key:lower() == "r" or key:upper() == "R" then
            print("Pressed the nitro")
        end
    end)
end
0
the humanoid has a sit property TwoTramp 18 — 3y

Answer this question