Hello fellow devs!
Now I am releasing Samurai Era, a restored medieval city of Japan.
For this experience, I have just made 10 kinds of fans as game passes.
These tools should be in a player’s tool box once purchased and I wrote the script as follows:
Blockquote
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
local SS = game:GetService(“ServerStorage”)
local SP = game:GetService(“StarterPack”)
local uchiwaStall = SS.UchiwaStall
local function onPlayerAdded(player)
for _, tool in pairs(uchiwaStall:GetChildren()) do
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, tool.PassID.Value)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass then
print(player.Name .. " owns the game pass with ID " .. tool.PassID.Value)
local clone = tool:Clone()
clone.Parent = SP
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Blockquote
Folder hierarchy is as follows:
When I start playing, These tools are displayed in my toolbox.
However, once I equip, I am transported forcefully to the fan shop
where I have changed the tools to models for display.
I cannot understand why I equip models on the shop, not tools cloned from Server Storage.
I will appreciate if someone help me.