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

How do I make a vehicle seat give you money?

Asked by 9 years ago

Hello!

I'm attempting to make a game (similar to driveblox I suppose) where every second driven you get so much money. I have a script from the actual original driveblox game to go by, but it isn't working. I have a leaderboard with a money stat, but I don't know how to get this to work. What I think is wrong is it isn't finding a person, how would I go about finding the persons name and having the script add money to the leaderboard??

local add = 935 --Change this!!

local db = 0
function onTouched(hit)
if db == 0 then
db = 1

local owner = script.Parent.Parent.Parent.Name
local user = game.Players:findFirstChild(owner)
local stats = user:findFirstChild("leaderstats")

---------- Cash Bonus ----------
while true do
wait()
if script.Parent.Throttle == 1 then 
wait(1)
local cash = stats:findFirstChild("Money")
cash.Value = cash.Value + add
end
end

db = 0
end
end

script.Parent.Touched:connect(onTouched)

The script resides in the model of the car. Any help please?

0
Could I use Occupant somehow? blueburns 10 — 9y

Answer this question