So I wanna make this lantern a tool a player can hold, and then once that’s done I wanna make the tool a gamepass then so on to the area popup. I hope you can help me with this problem, if you do I’ll give you credits on the game.
Ingame Image
So I wanna make this lantern a tool a player can hold, and then once that’s done I wanna make the tool a gamepass then so on to the area popup. I hope you can help me with this problem, if you do I’ll give you credits on the game.
You could an invisible part with can-collide set to false around the part and do something like:
--Client side code, place this in a local script inside the hitbox
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local part = script.Parent -- The hitbox
local gamePassID = 0000000 -- Change this to your game pass ID
-- Function to prompt purchase of the game pass
local function promptPurchase()
local player = Players.LocalPlayer
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass then
-- Player already owns the game pass; tell them somehow
else
-- Player does NOT own the game pass; prompt them to purchase
MarketplaceService:PromptGamePassPurchase(player, gamePassID)
end
end
local function onPartTouched(hit)
local model = hit.Parent
if model and model:IsA("Model") and players:GetPlayerFromCharacter(model) then
promptPurchase()
end
end
--Server side code
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 0000000 -- Change this to your game pass ID
local function onPlayerAdded(player)
local hasPass = false
-- Check if the player already owns the game pass
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
-- If there's an error, issue a warning and exit the function
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
print(player.Name .. " owns the game pass with ID " .. gamePassID)
-- Assign this player the ability or bonus related to the game pass
--
end
end
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == gamePassID then
print(player.Name .. " purchased the game pass with ID " .. gamePassID)
-- Assign this player the ability or bonus related to the game pass
--
end
end
-- Connect "PromptGamePassPurchaseFinished" events to the "onPromptGamePassPurchaseFinished()" function
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
I typed this out in the devforum and did not test it so sorry for any typos or if it does not work. Here is the article I got a lot of the code from: Article
Thanks for solving that problem, but now my problem is how would I make this lantern a player can hold as a tool.
I would try to take all of the parts, place them in a tool and put this script in a tool. qPerfectionWeld by Quenty Then I would name the main handle of the lantern handle
and use this plugin to rotate the handle how it should be help in the player’s hand. Tool Grip Editor by CloneTrooper1019
Thank you so much, I’ll give you the credits that you deserve
No problem! I am glad I could help!