I wrote this code, then I tested it. It worked, so I resize and play around with the part, and it suddenly stops working! Here is my code (Code block was too small, it shifted some things so sorry if it is messy):
script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.PlayerGui.test1.safe.TextLabel.TextColor3 = Color3.fromRGB(31, 198, 28) end) script.Parent.TouchEnded:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.PlayerGui.test1.safe.TextLabel.TextColor3 = Color3.fromRGB(198, 52, 54) end)
I want it so that when you touch the brick, there is a GUI that says safe. If you are outside of the brick (Not touching it) It would become red. If you are inside the brick (touching) then it is green. I can't figure this out.
I would really appreciate some help.
I figured out minutes after, lol. I forgot to add a debounce. The code should be:
script.Parent.Touched:Connect(function(hit) local Debounce = false if Debounce == false then Debounce = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.PlayerGui.test1.safe.TextLabel.TextColor3 = Color3.fromRGB(31, 198, 28) wait () Debounce = false end end) script.Parent.TouchEnded:Connect(function(hit) local Debounce = false if Debounce == false then Debounce = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.PlayerGui.test1.safe.TextLabel.TextColor3 = Color3.fromRGB(198, 52, 54) wait () Debounce = false end end)