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

in studio my game purchasing works perfectly fine, but in game it doesn't? [closed]

Asked by 6 years ago
Edited 6 years ago

Here are some videos showing it, look at my cash when I purchase the cars.

In Studio --

https://gyazo.com/09b5d3b41ac3dadbe0abc7d6e9b7a006

Out of studio --

https://gyazo.com/4005d53a5913bbbd73ae9bf5e32d9d7d

Out of studio, it takes the cash away then adds it back????

if you need to know more tag me in the discord..

local DSService = game:GetService('DataStoreService'):GetDataStore('Car00071isaproatscripting10202')
game.Players.PlayerAdded:connect(function(plr)
    -- Define variables
    local uniquekey = 'id-'..plr.userId
    local leaderstats = Instance.new('IntValue', plr)
    local savevalue =  Instance.new('IntValue')
    leaderstats.Name = 'leaderstats'
    savevalue.Parent = leaderstats
    savevalue.Name = 'Cash'

    -- GetAsync
    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        savevalue.Value = GetSaved[1]
    else
        local NumbersForSaving = {savevalue.Value}
        DSService:SetAsync(uniquekey, NumbersForSaving)
    end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Cash.Value}
DSService:SetAsync(uniquekey, Savetable)    


end)

game.ReplicatedStorage:WaitForChild("CheckPrice").OnServerInvoke = function(player, NameOfCar)

    return game.ServerStorage.Cars:FindFirstChild(NameOfCar).Price.Value
end

game.ReplicatedStorage:WaitForChild("SpawnCar").OnServerEvent:Connect(function(player,NameOfCar)
    local car = game.ServerStorage.Cars:FindFirstChild(NameOfCar):Clone()
car.PrimaryPart = car.Chassis
car:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame + Vector3.new(0,0,15))
car.Parent = workspace
car:MakeJoints()
car.Name = player.Name.."'s "..NameOfCar
end)



local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")
createPartEvent.Name = "CreatePartEvent"

local function onCreatePartFired(player)
    local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.StarterGui.PurchaseGUI.ScrollingFrame.Jugatti.Name)
    game.Players[tostring(player)].leaderstats.Cash.Value = game.Players[tostring(player)].leaderstats.Cash.Value - PriceOfItem
            script.Parent.Parent.StarterGui.PurchaseGUI.ScrollingFrame.Jugatti.Purchased.Value = true
end

createPartEvent.OnServerEvent:Connect(onCreatePartFired)
0
Don’t come on this site with alvinbloxx’s code, expecting for it to be fixed. User#19524 175 — 6y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?