Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI element blinking when walking on a part?

Asked by 3 years ago

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)
0
try deleting the away function because when you hit the block, it acts like the player keeps on jumping on it GameStealerKid 79 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
0
thats such a good work around, thanks! Phantom_User101 17 — 3y
0
np GameStealerKid 79 — 3y
Ad

Answer this question