Problem On Proximity Prompts

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to morph into a character after triggering a proximity prompt.
    I also Want To Fix the most unfixed and unexplained problem on all my roblox games.

  2. What is the issue? Include screenshots / videos if possible!

The proximity prompt is not working as expected. When activated, nothing happens and players are unable to morph into the desired character. I have checked the placement of the prompt and ensured that there are no conflicting scripts.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have reviewed the script responsible for the proximity prompt and ensured that it is correctly linked to the prompt. I have also double-checked the positioning and hierarchy of the objects involved. Additionally, I have examined the script for any syntax errors or logical issues, but everything seems to be in order.

I have not found any relevant solutions or similar issues on the Developer Hub or other resources.

local pad = script.Parent
local character = game.ServerStorage.C.TCM
local gamepassId = 193380940 -- Replace with the actual game pass ID

local debounce = true

local function OnPromptTriggered(triggeringPart)
	local plr = game.Players:GetPlayerFromCharacter(triggeringPart.Parent)
	if plr and debounce then
		debounce = false

		local success, hasGamePass = pcall(function()
			return game:GetService("MarketplaceService"):UserOwnsGamePass(plr.UserId, gamepassId)
		end)
		if success and hasGamePass then
			local charClone = character:Clone()
			charClone.Name = plr.Name
			plr.Character = charClone

			local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso")
			local plrRoot = triggeringPart.Parent:FindFirstChild("HumanoidRootPart") or triggeringPart.Parent:FindFirstChild("Torso")

			if rootPart and plrRoot then
				rootPart.CFrame = plrRoot.CFrame
			else
				warn("Failed to find root parts for positioning.")
			end

			charClone.Parent = workspace
		else
			print("You don't own the required game pass or an error occurred while checking game pass ownership.")
		end

		wait(5)
		debounce = true
	end
end

pad.ProximityPrompt.Triggered:Connect(OnPromptTriggered)

1 Like

The Triggered event returns the player, not the triggering player’s character or a part of their character so you are trying to get the player from Players service

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.