local debounce = false
local leave = script.Parent.CloseHitBox
local stop = script.Parent.OpenHitBox
local returner = script.Parent.ReturnHitBox
function close()
print("Close")
end
function open()
print("Open")
end
stop.Touched:Connect(function(hit)
if hit:IsA("VehicleSeat") and debounce == false then
debounce = true
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
player.leaderstats.Money = player.leaderstats.Money - 10
end
wait(1)
open()
returner.Touched:Connect(function(hit)
if hit:IsA("VehicleSeat") and debounce == true then
debounce = false
close()
end
end)
leave.TouchEnded:Connect(function(hit)
if hit:IsA("VehicleSeat") and debounce == true then
debounce = false
close()
end
end)
end
end)
I am trying to get the leaderstats.Money integer value from the player's character, but it only returns an "unable to define an index value"
Do I need to get the seatweld of the player for the seat and how do I do this if so?

1 comment
VehicleSeat.Occupant is all you should need, since Occupant is the Humanoid sitting in the seat