Hello!
I have this script for a vehicle where if a player doesn’t have enough cash, he gets kicked out of the seat. How do I make it so if the player doesn’t have enough cash, instead of being kicked, the player just cant enter the seat in the first place?
Here’s the script:
local vehicleSeat = script.Parent
local entryFee = 35
local playersWhoPaid = {}
vehicleSeat.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
-- Check if the player has already paid
if not playersWhoPaid[player.UserId] then
-- Assuming there's a leaderstats Cash value for the player
local cash = player:FindFirstChild("leaderstats"):FindFirstChild("Cash")
if cash and cash.Value >= entryFee then
cash.Value = cash.Value - entryFee
playersWhoPaid[player.UserId] = true
print(player.Name .. " has paid the entry fee.")
else
print(player.Name .. " does not have enough cash to enter.")
-- Prevent the player from sitting if they haven't paid
vehicleSeat.Disabled = true
task.wait(1) -- Wait for half a second before re-enabling the seat to avoid spamming
vehicleSeat.Disabled = false
end
else
print(player.Name .. " has already paid.")
end
end
end)