What do you want to achieve? I want to achieve Proximity Prompt that lets the player wear an morph accessory.
What is the issue? This probably sounds like an excuse. My head is filled with so much stress that I struggle with the code and I barely know what to do anymore.
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tried to search YouTube tutorials and I still don’t get it. I haven’t seen a Developer Hub post about something like this here. The only closest thing at least I think was this post: Morph Kit Thing - Help and Feedback / Creations Feedback - DevForum | Roblox
I suck at coding and sometimes I barely know what I am supposed to do. I know this isn’t the place where you ask for code.
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Lantern") == nil then
local g = script.Parent.Parent.Lantern:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "UnionOperation"or C[i].className == "Part" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Torso
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched)
This is the code I have been trying to change. I have 3 scripts that are used.
function onTouched(hit)
local d = hit.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Hat") then
d[i].Handle.Transparency = 1
end
end
end
script.Parent.Touched:connect(onTouched)
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if human ~= nil then
part.Parent:findFirstChild("Head").Transparency = 1
part.Parent:findFirstChild("Torso").Transparency = 1
part.Parent:findFirstChild("Left Arm").Transparency = 1
part.Parent:findFirstChild("Right Arm").Transparency = 1
part.Parent:findFirstChild("Left Leg").CanCollide = true
part.Parent:findFirstChild("Left Leg").Transparency = 1
part.Parent:findFirstChild("Right Leg").CanCollide = true
part.Parent:findFirstChild("Right Leg").Transparency = 1
end
end
script.Parent.Touched:connect(onTouch)
Quite frankly, there is nothing major to debug. He isn’t an experienced programmer and is still learning how things work so obviously didn’t expect him to know how to trigger a proximity prompt.
It’s only about two words that had to be replaced.
Using proximity prompt service, you can detect whenever a proximity prompt is activated. Then, you check if it is the prompt you are trying to detect, and run the code if it is.
(the example they give is below)
local ProximityPromptService = game:GetService("ProximityPromptService")
-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)
end
-- Detect when prompt hold begins
local function onPromptHoldBegan(promptObject, player)
end
-- Detect when prompt hold ends
local function onPromptHoldEnded(promptObject, player)
end
-- Connect prompt events to handling functions
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)
ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)
In this example, we fire function “onPromptTriggered” when ANY prompt is triggered.
There are two parameters to the function “onPromptTriggered,” which are the prompt that was triggered (Instance), and the player who did it.
Make sure the script is in the proximity prompt (place this script under the proximity prompt). The parent of the script should be the proximity prompt.
If we want to see when the prompt gets triggered, the code would look something like this.
local function onPromptTriggered(promptObject, player)
if promptObject == script.Parent then -- Check if the activated prompt is the one we are looking for (the script's parent)
print(player) -- this should print the player instance of the person who activated it
end
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)