anyway uh, i hope code with comments will be enough of an explanation
oh yeah and output
function SetActionText(hoveredObject, actionText: TextLabel)
if hoveredObject.Name == "Crate" or "Locker" then -- Efficient? I don't know
print("setting to open for some reason") -- This ALWAYS runs
actionText.Text = "E - Open"
else
actionText.Text = "E - Take" -- runs literally never
end
end
function OnPromptShown(prompt: ProximityPrompt, inputType: Enum) -- SetActionText gets called at the bottom
if prompt.Style == Enum.ProximityPromptStyle.Default then return end
local clonedPrompt = storedPrompt:Clone()
clonedPrompt.Parent = proximityPromptsUI
local popupSound = clonedPrompt:WaitForChild("Popup")
popupSound:Play()
-- Prompt contents;
local lowerPromptFrame = clonedPrompt:WaitForChild("LowerFrame")
local upperPromptFrame = clonedPrompt:WaitForChild("UpperFrame")
local objectText = upperPromptFrame:WaitForChild("ObjectText")
local actionText = lowerPromptFrame:WaitForChild("ActionText")
-- Get the hovered object instance type
local hoveredObject = prompt:FindFirstAncestorWhichIsA("Tool") or prompt:FindFirstAncestorWhichIsA("Model")
print(hoveredObject.ClassName, hoveredObject.Name)
if not hoveredObject then warn("Unable to find a tool or model instance as ancestors!") return end
clonedPrompt.Adornee = hoveredObject
objectText.Text = hoveredObject.Name
SetActionText(hoveredObject, actionText)
CreateHighlight(hoveredObject)
end
function SetActionText(hoveredObject, actionText: TextLabel)
if hoveredObject.Name == "Crate" or hoveredObject.Name == "Locker" then -- Efficient? I don't know
print("setting to open for some reason") -- This ALWAYS runs
actionText.Text = "E - Open"
else
actionText.Text = "E - Take" -- runs literally never
end
end
function OnPromptShown(prompt: ProximityPrompt, inputType: Enum) -- SetActionText gets called at the bottom
if prompt.Style == Enum.ProximityPromptStyle.Default then return end
local clonedPrompt = storedPrompt:Clone()
clonedPrompt.Parent = proximityPromptsUI
local popupSound = clonedPrompt:WaitForChild("Popup")
popupSound:Play()
-- Prompt contents;
local lowerPromptFrame = clonedPrompt:WaitForChild("LowerFrame")
local upperPromptFrame = clonedPrompt:WaitForChild("UpperFrame")
local objectText = upperPromptFrame:WaitForChild("ObjectText")
local actionText = lowerPromptFrame:WaitForChild("ActionText")
-- Get the hovered object instance type
local hoveredObject = prompt:FindFirstAncestorWhichIsA("Tool") or prompt:FindFirstAncestorWhichIsA("Model")
print(hoveredObject.ClassName, hoveredObject.Name)
if not hoveredObject then warn("Unable to find a tool or model instance as ancestors!") return end
clonedPrompt.Adornee = hoveredObject
objectText.Text = hoveredObject.Name
SetActionText(hoveredObject, actionText)
CreateHighlight(hoveredObject)
end
Oh I just watched the video and I see what you mean now.
So I’d specifically set each ActionText for each interactable object.
if part.Name == "Locker" or part.Name == "Door" then
-- set ActionText to "Open"
elseif part.Name == "BaseballBat" then
-- set ActionText to "Equip" or "Take"