TextLabel text for some reason bypasses the requirements that are needed for a specific string to be shown

what a horrible title

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

image

literally what?

Can you explain in more detail…

man;

i really don’t know how to explain this in greater detail i’m gonna be honest :sob:

the action text of the proximity prompt does NOT change accordingly to the object type (if that makes sense)

instead it always runs the if object.Name == "Locker" or "Crate" then statement, never the else statement

why? i have no idea

I dont think if statments work like that.

Try this

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

So you’re changing the proximity prompt’s action text depending on what the actual object is? Well, I could just do this:

-- imagine we have the variables for ProximityPrompt and the Part with the prompt.

proximityPrompt.ActionText = part.Name
1 Like

okay but how was i supposed to know that???

:rage:

1 Like

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"
1 Like

no that would infact be very bad practice

@5smokin fixed it anyway

stupidest mistake ever i think

1 Like

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