Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI element blinking when walking on a part?

Im trying to make it so when i stand on top of a part a text button is visible, and when i step off the part it becomes invisible, i tried this code (Server Script) and it kinda works but it blinks each time i move on the part, how can i make it so it doesnt blink? I also have a video of the issue so here is is, https://streamable.com/ypnkli

local Players = game.Players
     
local function Touched(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if player ~= nil then
        player.PlayerGui.ScreenGui.TextButton.Visible = true
    end
end
local function Away(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if player ~= nil then
        player.PlayerGui.ScreenGui.TextButton.Visible = false
    end    
end

script.Parent.Touched:Connect(Touched)
script.Parent.TouchEnded:Connect(Away)

1 comment

0

try deleting the away function because when you hit the block, it acts like the player keeps on jumping on it

1 answer

✓ Accepted answer

try deleting the away function because when you hit the block, it acts like the player keeps on jumping on it. so, put block around it with the away function so basically it would be like

Camera block script:

local Players = game.Players
 
local function Touched(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if player ~= nil then
        player.PlayerGui.ScreenGui.TextButton.Visible = true
    end
end

script.Parent.Touched:Connect(Touched)

Camera gui stopper (blocks around the camera block):

local Players = game.Players
 
local function Away(hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if player ~= nil then
        player.PlayerGui.ScreenGui.TextButton.Visible = false
    end
end

script.Parent.Touched:Connect(Away)

2 comments

0

thats such a good work around, thanks!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.