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

How would I make this define all vehicle seats?

Asked by 4 years ago
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local player = script.Parent.Name
local PlayPlayer = game.Players:FindFirstChild(player)
local Sitting = false



humanoid.Seated:Connect(function(isSeated, seat)
    if isSeated then
        if seat == workspace.INSPARE.DriveSeat then
            Sitting = true

            while true do
                wait(1)
                if Sitting == true then
                PlayPlayer.leaderstats.Cash.Value = PlayPlayer.leaderstats.Cash.Value + 1
                end
            end
        end
    else
        print("The Player Stopped Sitting")
        Sitting = false
    end
end)

Hello, I found this code on the devfourms but I don't know how to how to make it define all of the vehicle seats in the workspace. I want to change this line of code:

if seat == workspace.INSPARE.DriveSeat then

Everytime i've tried to fix it it just gives an error. Please help!

1 answer

Log in to vote
1
Answered by 4 years ago

The answer to this is pretty simple. ^w^

Code:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local player = script.Parent.Name
local PlayPlayer = game.Players:FindFirstChild(player)
local Sitting = false



humanoid.Seated:Connect(function(isSeated, seat)
    if isSeated then
            Sitting = true

            while true do
                wait(1)
                if Sitting == true then
                PlayPlayer.leaderstats.Cash.Value = PlayPlayer.leaderstats.Cash.Value + 1
                end
        end
    else
        print("The Player Stopped Sitting")
        Sitting = false
    end
end)

All we had to do was remove the "if seat ==" line, and now it triggers for every seat. Hope this helped. ^w^

0
im an complete idiot, thanks! Spiyder1 81 — 4y
0
ur welcome c: iOriena3 67 — 4y
Ad

Answer this question