I was working on an alarm system that occurs when a part with a text button is clicked. I have got pretty far but I am stuck on the part where I want the ui to change it’s size every second until the reinforcements come. My code does not work, and I think it has something to do with accessing the startergui from workspace. There are no errors. Here are some pictures:
Basically when you put something inside of StarterGui it’s actually replicated to all the players’ PlayerGuis, so the path to them would have to be plr.PlayerGui
warn("ALARM STARTED")
plr.PlayerGui.AlarmUi.Outline.Time.Size = UDim2.new(0, 50, 0, 37)
---rest of the code is the same except I replace game.Startergui with plr---
You need to get the player from the click detector use it to then get the Player GUI
do something like this
local AlarmOn -- used as debounce
function UIAlarmChanges(player)
local PlayerGUI = player:FindFirstChild('PlayerGui') -- fine that players ui that clicked the object
if not PlayerGUI then return end -- no ui so just exit function
PlayerGUI.AlarmUI.OutLine.Time.Size = UDim2.new(0,50,0,37)
wait(1)
---- add the rest in here
end
script.Parent.AlarmPiece.StartAlert.ClickDetector.MouseClick:Connect(function(player)
if AlarmOn then return end -- the alarm is already on so exit function
AlarmOn = true
UIAlarmChanges(player)
AlarmOn = false
end)