hello i am trying to make a script that when you drive it gives you money but i am having trouble finding the (working) script for it. . . either i am not setting up the script right or i dont know ive been looking on youtube for a long time and i cant find any. i have looked on script helpers (this site) but none of them work or im just not setting them up. . . help
COMMUNITY QUESTION
i want a script that gives the player money whilst driving?
1 answer
To answer Your question, here is what I've Made For you /Note: If You Are Planning To Make A Game, You Do Not Need to Credit Me
First Put This Script In ServerScriptService:
local DataStore = game:GetService("DataStoreService")
local CoinsData = DataStore:GetDataStore("CoinsData")
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("BoolValue",plr)
stats.Name = "leaderstats"
local coins = Instance.new("IntValue",stats)
coins.Name = "Coins"
coins.Value = 0
local data
local success, errormessage = pcall(function()
data = CoinsData:GetAsync(plr.UserId.."-Coins")
end)
if success then
coins.Value = data
else
print("There Was An Error While Getting A Players Data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
CoinsData:SetAsync(plr.UserId.."-Coins",plr.leaderstats.Coins.Value)
end)
if success then
print("Player Data Was Saved")
else
print("There Was A Error When Saving Players Data")
warn(errormessage)
end
end)
/Note: This Will Save A Players Data As Well As Keep It.
Next, Put This Script Inside The Vehicle Seat
toggle = false
while true do wait()
if script.Parent.Occupant ~= nil and toggle == false then
toggle = true
local playerHum = script.Parent.Occupant
local playerName = playerHum.Parent.Name
local Player = game.Players:WaitForChild(playerName)
local leaderStats = Player:WaitForChild("leaderstats") -- Grabs Leaderstats
local coins = leaderStats:WaitForChild("Coins") -- Grabs Coins
wait(3) -- Time You Want To Wait Before Cash Reward
coins.Value = coins.Value + 100 -- Cash You Want To Reward
toggle = false -- Turns Toggle To False
end
end
/Note: If You Are Changing The Currency Name You Must Change It In Both Scripts
If This Has Helped You Please Accept It as an Answer.
I hope I Helped You
1 comment
1
Spoon feeding at its finest.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
i needed the question mark in the title if you were wondering
When you turn a statement/demand into a "question" by adding a question mark, lol