Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I change this to a on click instead of touch?

Asked by 4 years ago
local MarketplaceService = game:GetService("MarketplaceService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local teleporter = script.Parent
local showPrompt = true

local placeID_Premium = 012345678

local function onTeleporterTouch(otherPart)

    local player = Players:GetPlayerFromCharacter(otherPart.Parent)
    if not player then return end

    -- If the user already has Premium, teleport them to the Premium-only place
    if player.MembershipType == Enum.MembershipType.Premium then
        TeleportService:Teleport(placeID_Premium, player)
    -- Else, prompt Premium upgrade (use debounce to show it only once every few seconds)
    else
        if showPrompt == false then return end
        showPrompt = false
        delay(5, function()
            showPrompt = true
        end)
        MarketplaceService:PromptPremiumPurchase(player)
        warn("Prompted Premium purchase")
    end
end
teleporter.Touched:Connect(onTeleporterTouch)

-- If needed, use this event to know when the Premium modal is closed
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
    warn("Premium modal closed")
end)

-- Handle potential Premium purchase from outside the game while user is playing
Players.PlayerMembershipChanged:Connect(function(player)
    warn("Player membership changed; new membership is " .. tostring(player.MembershipType))
    if player.MembershipType == Enum.MembershipType.Premium then
        -- Teleport player to the Premium-only place
        TeleportService:Teleport(placeID_Premium, player)
    end
end)
0
Add a click detector BradNewTypical 232 — 4y
0
Yeah Ik but what do I change in the script? no0bgaming748 24 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Change teleporter variable to refer to a ClickDetector.

change teleporter.Touched:connect... to teleporter.MouseClick:connect...

etc.

Ad
Log in to vote
0
Answered by 4 years ago

Its actually pretty simple. 1. Put in a ClickDetector.

teleporter.ClickDetector.MouseClick:Connect(onTeleporterTouch)

assuming this is the line that you wanted converted to click, this should help you out.

0
thats a simple way of doing it i geuss so ye pretty simple Vetrodex 22 — 3y

Answer this question