You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i want the action text to change if the action text = the gun name in the table
What is the issue? Include screenshots / videos if possible!
the script shows the action = either the gun or gun2 in the print yet prompts it to “buy” instead of “take”
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
tried string.match, tried tables, tried :GetChildren().
local action = script.Parent.Parent.ActionText.Text
local player = game.Players.LocalPlayer
local gun = {}
for i,v in pairs(game.Lighting.WEAPONSBOX:GetChildren()) do
table.insert(gun,v.Name)
end
local UserInputService = game:GetService("UserInputService")
--HERE
if action == "Barrier" then
script.Parent.Text = `Hold <font color="rgb(225,225,0)">F</font> to repair Barrier`
else
for i,v in pairs(game.Lighting.WEAPONSBOX:GetChildren()) do
if action == v.Name then
script.Parent.Text = `Hold <font color="rgb(225,225,0)">F</font> to Take {action}`
else
script.Parent.Text = `Hold <font color="rgb(225,225,0)">F</font> to Buy {action}`
end
end
end
so basically in weaponbox theres tools, i want to make it so if the proxyprompt action text matches the table or get children (so if the action text = “AK47” then ‘do stuff’ ) it’ll display the “take” text and if it doesnt match it’ll display the “buy” text.
The issue is if theres like one or 2 guns it’ll work. but adding in more tools i’ll get the “buy” text instead of the “take” text.
i added print statements. ironically the action text will print a gun in the weapons box, and the v will print the same value, yet it’ll display the “buy” text as if the action text does not match the v.Name…?
Why is there a BillboardGui in your StarterPlayerScripts?
I tried recreating it without the GUI element (I’m just printing it out) with just a LocalSript in StarterPlayerScripts and “action” being set to a string named “Part1” (one of the parts I had in “WEAPONSBOX”), and it seems to work for me.
Also, what is the text in ActionText and are there any errors? Is there anything modifying ActionText? Have you tried replacing it with just a string to test it out?
I also noticed that the script selected is grayed out, which usually means a script is disabled. Is the “Enabled” property on for that script?
I get no errors, and it works if theres 1 or 2 tools in weaponbox but with all of the tools it’ll display “hold F to buy (tool)” instead of “hold F to take (tool)” with no error
I even added a print statement for “action” and “v.Name” and both will display the same value, yet the script will handle it as if they are not the same value(again it works with 1 or 2 tools)
The disabled one is just something i was working on earlier (had some stuff for mobile + xbox detection) that i’ll work on once i get this working properly