Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make this define all vehicle seats?

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

✓ Accepted answer

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^

2 comments

0

im an complete idiot, thanks!

0

ur welcome c:

This discussion is preserved as it was. New answers, comments, and votes are closed.