I need a data store to save a booth using a proximity prompt and a game pass purchased. I want the booth to load for the player the next time they enter the game.
I’m not very good with datastores. I have them working for leader stats but when it comes to trying to incorporate it outside of leader stats I’m not doing too good.
I have researched here on the forums for information to help and I’ve practiced and tried different ways to no avail yet.
I do have a booth currently that can be obtained via the proximity prompt. I learned this watching a you tube tutorial. I want to add the game pass into the prompt, where the player has to have the game pass at the time of the prompt trigger, in order to get the booth. My proximity prompt function looks at the remote event value with an if statement. So I thought that I could include something in the if statement, but I’ve not been able to get this to work yet.
Then with the data store, I was trying to have the booth entered into the players newly created inventory folder to save it so upon re entry the booth is still theirs to be loaded. Upon player adding it loads a clone of the booth, upon removing it adds it to the inventory folder. I tried this using the proximity prompt as well but could not get it to work.
I think my issue is in how i structure and write the code out b/c I do understand what I am trying to accomplish.
Any suggestions ?
My Code for data store
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local dataservice = game:GetService("DataStoreService")
local ServerStorage = game:GetService("ServerStorage")
local inventorydata = dataservice:GetDataStore("player_data")
local booth = game.Workspace:GetChildren("Booth")
local prox = game.Workspace.Booth.Prompt.ProximityPrompt
local pp = game.Workspace.Booth.Prompt:WaitForChild("ProximityPrompt")
inv = {}
game.Players.PlayerAdded:Connect(function(player)
local inventory = Instance.new("Folder")
inventory.Name = "inventory"
inventory.Parent = player
pp.Triggered:Connect(function(player)
--print("triggered")
--prox.Enabled = true
--if proxprompt.Enabled == true then
--if prox.Enabled == true then
table.insert(inv, booth)
print("booth")
--end
--end
end)
local inv = inventorydata:GetAsync(player.UserId) or {}
for i, v in pairs(player.inventory:GetChildren(booth)) do
local booth = inventory:Clone()
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local inv = {}
for i, v in pairs(player.inventory:GetChildren(inv)) do
table.insert(inv,player.booth)
end
end)
My code for Booth, Proximity Prompt
local prox = script.Parent
local boothModel = prox.Parent.Parent
local topSign = boothModel.TopSign
local BottomPart = boothModel.BottomPart
local claimedBoothRemote = game.ReplicatedStorage.ClaimedBooth
local editBoothRemote = game.ReplicatedStorage.EditBooth
prox.Triggered:Connect(function(plr)
local claimedBooth = plr.ClaimedBooth
if claimedBooth.Value == nil then
prox.Enabled = false
claimedBooth.Value = boothModel
BottomPart.SurfaceGui.PlayerName.Text = plr.Name.. "'s Booth"
topSign.SurfaceGui.ImageLabel.Image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
claimedBoothRemote:FireClient(plr, boothModel)
elseif claimedBooth.Value == boothModel then
editBoothRemote:FireClient(plr)
end
end)
My Booth proximity prompt setup
My remote Vent in Replicated Storage
My Inventory folder when the game is started sitting under Players