Hello everyone, like I usually say I’m new to scripting so please be patient with me. The way this works, is a player picks up a tool on the map (“Radio”). When the player equips the tool in their inventory, a ScreenGui appears (“RadioGui”). I want to script a progress bar, that only shows when the tool is equipped (along with the RadioGui). I need the progress bar to move, or increase, when a player clicks a certain part on the map while the tool is equipped. Here is the code I have now listed below; along with screenshots of my setup. So far the only thing that works is the RadioGui appearing once the tool is equipped. If anyone has any intel, helpful links, or experience with this, I would greatly appreciate your help.
local Ui = script:WaitForChild("RadioGui") -- Gui Name Here
script.Parent.Equipped:Connect(function()
local ScreenGui = Ui:Clone()
ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui
end)
script.Parent.Unequipped:Connect(function()
game.Players.LocalPlayer.PlayerGui:FindFirstChild(Ui.Name):Destroy()
end)
local Ui = script:WaitForChild("RadioGui") -- Gui Name Here
local progressBar = Ui:WaitForChild("ProgressBar") -- progress bar Frame name here
local clickPart = game.Workspace:WaitForChild("Radio1") -- The part you want the player to click on
script.Parent.Equipped:Connect(function()
local ScreenGui = Ui:Clone()
ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui
end)
script.Parent.Unequipped:Connect(function()
game.Players.LocalPlayer.PlayerGui:FindFirstChild(Ui.Name):Destroy()
end)
local function handleClick()
-- Increase the progress bar size by a certain amount
progressBar.Size = progressBar.Size + UDim2.new(1, 1, 1, 1) -- Adjust the amount as needed
end
clickPart.ClickDetector.MouseClick:Connect(handleClick)
In the screenshot, what is labeled “Script” is just for a proximity prompt for the radio, the “LocalScript” is what I included above.
The part the player needs to click is labeled “Radio1”, and only consists of a click detector.