I am making a game which has shops for in-game currency and I need to save whether the player owns the items in the shop or not while using data store and bool values I have a local script which is located within the shop GUI with a script that allows the item to be purchased but now I just need the script to save the bool value here are the scripts:
LOCAL SCRIPT
local function purchaseFunc()
if selectedTag.Value == "survivor" then
if itemFrame:WaitForChild('Survivor'):WaitForChild('Owned').Value == false then
if player:WaitForChild('leaderstats'):WaitForChild('Money').Value > 50 then
game:GetService("ReplicatedStorage"):WaitForChild('Events'):WaitForChild('RemoteEvents'):WaitForChild('ShopEvents'):WaitForChild('tagShopEvents'):WaitForChild('TagShopSurvivorPurchased'):FireServer(player)
purchase.Text = 'Check Inventory To Equip "Survivor" tag!'
elseif itemFrame:WaitForChild('Survivor'):WaitForChild('Owned').Value == true then
purchase.Text = 'You Already Own "Survivor" tag!'
end
end
end
end
local function survivor()
descriptionPrice.Text = "$50"
descriptionTitle.Text = "Survivor Tag"
selectedTag.Value = "survivor"
end
local function fighter()
descriptionPrice.Text = "$50"
descriptionTitle.Text = "Fighter Tag"
selectedTag.Value = "fighter"
end
local function killer()
descriptionPrice.Text = "$175"
descriptionTitle.Text = "Killer Tag"
selectedTag.Value = "killer"
end
purchase.MouseButton1Click:Connect(purchaseFunc)
itemFrame:WaitForChild('Killer').MouseButton1Click:Connect(killer)
itemFrame:WaitForChild('Fighter').MouseButton1Click:Connect(fighter)
itemFrame:WaitForChild('Survivor').MouseButton1Click:Connect(survivor)
Server Script
local event = game:GetService('ReplicatedStorage'):WaitForChild('Events'):WaitForChild('RemoteEvents'):WaitForChild('ShopEvents'):WaitForChild('tagShopEvents'):WaitForChild('TagShopEvent')
local survivor_bool = game:GetService('ReplicatedStorage'):WaitForChild('Values'):WaitForChild('TagShopValues'):WaitForChild('SurvivorBool')
local fighter_bool = game:GetService('ReplicatedStorage'):WaitForChild('Values'):WaitForChild('TagShopValues'):WaitForChild('SurvivorBool')
local killer_bool = game:GetService('ReplicatedStorage'):WaitForChild('Values'):WaitForChild('TagShopValues'):WaitForChild('SurvivorBool')
local dataStoreService = game:GetService('DataStoreService')
local function purchase(player, value)
if value == "survivor" then
player:WaitForChild("leaderstats"):WaitForChild('Money').Value -= 50
survivor_bool.Value = true
end
if value == "fighter" then
player:WaitForChild("leaderstats"):WaitForChild('Money').Value -= 50
fighter_bool.Value = true
end
if value == "killer" then
player:WaitForChild("leaderstats"):WaitForChild('Money').Value -= 50
killer_bool.Value = true
end
end
event.OnServerEvent:Connect(purchase)
I need to save the bool values from the server script once the event is called for them and save the value to the data store, Thanks,