Im trying to make a donating game and i cant find the issue in my scripts but the gamepasses so not show for some reason.
I’m probably not going to get a lot of help because there are a lot of lines of code
This is the first script located in ServerScriptService (Normal Script)
local module = require(script.Parent.MainModule)
local textService = game:GetService("TextService")
local mps = game:GetService("MarketplaceService")
local dss = game:GetService("DataStoreService")
local donationStore = dss:GetDataStore("MainStore")
local http = game:GetService("HttpService")
local joinedroation = game.ReplicatedStorage.Events.JoinedRotation
local function claimBoothRandomly(player)
local unclaimedBooths = {}
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if not stand.Claimed.Value then
table.insert(unclaimedBooths, stand)
end
end
if #unclaimedBooths > 0 then
local randomBooth = unclaimedBooths[math.random(1, #unclaimedBooths)]
randomBooth.Claimed.Value = true
randomBooth.ClaimedUserName.Value = player.Name
randomBooth.Base.Unclaimed.Enabled = false
randomBooth.Base.ClaimedInfoDisplay.UserName.Text = player.Name
randomBooth.Base.ClaimedInfoDisplay.Enabled = true
-- Teleport the player's HumanoidRootPart to TPpart inside the booth (for R15 characters)
local TPpart = randomBooth:FindFirstChild("TPpart")
if TPpart and TPpart:IsA("Part") then
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart and humanoidRootPart:IsA("Part") then
humanoidRootPart.CFrame = TPpart.CFrame
-- Set the player's WalkSpeed and JumpHeight to 0
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
end
end
end
end
else
print("All booths are claimed.")
end
end
joinedroation.OnServerEvent:Connect(claimBoothRandomly)
game.ReplicatedStorage.Events.EditStand.OnServerEvent:Connect(function(plr,text)
local filtered = textService:FilterStringAsync(text,plr.UserId):GetNonChatStringForBroadcastAsync()
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if stand.Claimed.Value == true and stand.ClaimedUserName.Value == plr.Name then
stand.MessagePart.SurfaceGui.UserMessage.Text = filtered
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local donated = Instance.new("IntValue",leaderstats)
donated.Name = "Donated"
local received = Instance.new("IntValue",leaderstats)
received.Name = "Received"
local data
local success, errormsg = pcall(function()
data = donationStore:GetAsync(plr.UserId)
end)
if success then
if data then
data = http:JSONDecode(data)
donated.Value = data[1]
received.Value = data[2]
else
print("No previous data.")
end
else
warn(errormsg)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = {plr.leaderstats.Donated.Value,plr.leaderstats.Received.Value}
local success, errormsg = pcall(function()
data = http:JSONEncode(data)
donationStore:SetAsync(plr.UserId,data)
end)
if success then
print("Successfully saved.")
else
warn(errormsg)
end
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if stand.ClaimedUserName.Value == plr.Name then
module.clearStand(stand)
end
end
end)
mps.PromptGamePassPurchaseFinished:Connect(function(plr, passId, purchased)
if purchased == true then
print("Purchased.")
local item = module.findItem(passId)
local cost = item.Cost.Value
local plrBy = game.Players:FindFirstChild(item.Parent.Parent.Parent.Parent.ClaimedUserName.Value)
if cost then
print(cost)
plr.leaderstats.Donated.Value += cost
else
print("Could not find cost.")
end
if plrBy then
plrBy.leaderstats.Received.Value += cost -- Corrected name to "Received"
else
print("Could not find PlrBy.")
end
module.updateStandsEarned()
else
print("Not purchased.")
end
end)
mps.PromptPurchaseFinished:Connect(function(plr, assetId, purchased)
if purchased == true then
print("Purchased.")
local item = module.findItem(assetId)
local cost = item.Cost.Value
local plrBy = game.Players:FindFirstChild(item.Parent.Parent.Parent.Parent.ClaimedUserName.Value)
if cost then
print(cost)
plr.leaderstats.Donated.Value += cost
else
print("Could not find cost.")
end
if plrBy then
plrBy.leaderstats.Received.Value += cost -- Corrected name to "Received"
else
print("Could not find PlrBy.")
end
module.updateStandsEarned()
end
end)
and this is the second script also in ServerScriptService (Module Script)
local module = require(script.Parent.MainModule)
local textService = game:GetService("TextService")
local mps = game:GetService("MarketplaceService")
local dss = game:GetService("DataStoreService")
local donationStore = dss:GetDataStore("MainStore")
local http = game:GetService("HttpService")
local joinedroation = game.ReplicatedStorage.Events.JoinedRotation
local function claimBoothRandomly(player)
local unclaimedBooths = {}
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if not stand.Claimed.Value then
table.insert(unclaimedBooths, stand)
end
end
if #unclaimedBooths > 0 then
local randomBooth = unclaimedBooths[math.random(1, #unclaimedBooths)]
randomBooth.Claimed.Value = true
randomBooth.ClaimedUserName.Value = player.Name
randomBooth.Base.Unclaimed.Enabled = false
randomBooth.Base.ClaimedInfoDisplay.UserName.Text = player.Name
randomBooth.Base.ClaimedInfoDisplay.Enabled = true
-- Teleport the player's HumanoidRootPart to TPpart inside the booth (for R15 characters)
local TPpart = randomBooth:FindFirstChild("TPpart")
if TPpart and TPpart:IsA("Part") then
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart and humanoidRootPart:IsA("Part") then
humanoidRootPart.CFrame = TPpart.CFrame
-- Set the player's WalkSpeed and JumpHeight to 0
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
end
end
end
end
else
print("All booths are claimed.")
end
end
joinedroation.OnServerEvent:Connect(claimBoothRandomly)
game.ReplicatedStorage.Events.EditStand.OnServerEvent:Connect(function(plr,text)
local filtered = textService:FilterStringAsync(text,plr.UserId):GetNonChatStringForBroadcastAsync()
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if stand.Claimed.Value == true and stand.ClaimedUserName.Value == plr.Name then
stand.MessagePart.SurfaceGui.UserMessage.Text = filtered
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local donated = Instance.new("IntValue",leaderstats)
donated.Name = "Donated"
local received = Instance.new("IntValue",leaderstats)
received.Name = "Received"
local data
local success, errormsg = pcall(function()
data = donationStore:GetAsync(plr.UserId)
end)
if success then
if data then
data = http:JSONDecode(data)
donated.Value = data[1]
received.Value = data[2]
else
print("No previous data.")
end
else
warn(errormsg)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = {plr.leaderstats.Donated.Value,plr.leaderstats.Received.Value}
local success, errormsg = pcall(function()
data = http:JSONEncode(data)
donationStore:SetAsync(plr.UserId,data)
end)
if success then
print("Successfully saved.")
else
warn(errormsg)
end
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
if stand.ClaimedUserName.Value == plr.Name then
module.clearStand(stand)
end
end
end)
mps.PromptGamePassPurchaseFinished:Connect(function(plr, passId, purchased)
if purchased == true then
print("Purchased.")
local item = module.findItem(passId)
local cost = item.Cost.Value
local plrBy = game.Players:FindFirstChild(item.Parent.Parent.Parent.Parent.ClaimedUserName.Value)
if cost then
print(cost)
plr.leaderstats.Donated.Value += cost
else
print("Could not find cost.")
end
if plrBy then
plrBy.leaderstats.Received.Value += cost -- Corrected name to "Received"
else
print("Could not find PlrBy.")
end
module.updateStandsEarned()
else
print("Not purchased.")
end
end)
mps.PromptPurchaseFinished:Connect(function(plr, assetId, purchased)
if purchased == true then
print("Purchased.")
local item = module.findItem(assetId)
local cost = item.Cost.Value
local plrBy = game.Players:FindFirstChild(item.Parent.Parent.Parent.Parent.ClaimedUserName.Value)
if cost then
print(cost)
plr.leaderstats.Donated.Value += cost
else
print("Could not find cost.")
end
if plrBy then
plrBy.leaderstats.Received.Value += cost -- Corrected name to "Received"
else
print("Could not find PlrBy.")
end
module.updateStandsEarned()
end
end)
this is the 3rd script located in starterplayerscripts (local scripts)
local mps = game:GetService("MarketplaceService")
while wait(1) do
for _, stand in pairs(game.Workspace.Stands:GetChildren()) do
for _, frame in pairs(stand:WaitForChild("Products").Items.ScrollingFrame:GetChildren()) do
if frame:IsA("Frame") then
frame.RobuxCost.MouseButton1Click:Connect(function()
if frame.ItemTypeId.Value == 34 then
mps:PromptGamePassPurchase(game.Players.LocalPlayer, frame.ItemID.Value)
else
mps:PromptPurchase(game.Players.LocalPlayer, frame.ItemID.Value)
end
end)
end
end
if stand.Claimed.Value == true then
if stand.ClaimedUserName.Value == game.Players.LocalPlayer.Name then
-- Update the raised amount in ClaimedInfoDisplay
local plrBy = game.Players:FindFirstChild(stand.ClaimedUserName.Value)
if plrBy then
stand.Base.ClaimedInfoDisplay.UserRaised.Text = "R$" .. tostring(plrBy.leaderstats.Received.Value) .. " Raised"
else
print("Could not find player: " .. stand.ClaimedUserName.Value)
end
end
end
end
end
This shows the location of all the items in the stands