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

How to make racing game goal that awards cash?

Asked by 5 years ago

So im making a Racing game for my Friend (XPrenupX on twitch) and i want to make a end goal that depending on if your 1st or 3rd you get different amounts of cash

this is what i got am im not sure what to do next?

local cashprize = 1000
local player = game.Players.LocalPlayer
local recent = 0 -- what ever place is next (1st,2nd,3rd,etc.)

script.Parent.Touched:connect(function(hit)
    local b = hit.Parent:FindFirstChild("Humanoid")
    if b ~= nil then
    player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + cashprize --for 1st place

    end
end)

i'm thinking of adding a if statement like this but i've done this already and i didnt give me the cash.

if recent == 0 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + cashprize --for 1st place
end
if recent == 1 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + cashprize/2 --for 2nd place
end
if recent == 2 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + cashprize/2/2 --for 3rd place
end

im not sure what im doing wrong here...

0
LocalPlayer is nil on the server. User#19524 175 — 5y
0
Weird, the first time i tried it, it worked Deadlox59sAlt 0 — 5y
0
on studio, the client and the server is the same, which many people forget about, while in the client, the two are separated, meaning that LocalPlayer is set in studio with the script's side not mattering, while you must use a localscript as LocalPlayer is a client sided property (like workspace.CurrentCamera) fanofpixels 718 — 5y

Answer this question