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

I made this script, it works, but sometime its "buggy and glitchy". help?

Asked by 5 years ago

heres the script I made local Part = script.Parent

Part.Touched:Connect(function(HIT)

local H = HIT.Parent:FindFirstChild("Humanoid")

if H then

local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)

Player.PlayerGui.ScreenGui.Frame.Visible = true

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 1

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .9

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .8

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .7

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .6

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .5

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .4

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .3

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .2

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .1

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 0

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .1

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .2

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .3

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .4

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .5

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .6

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .7

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .8

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = .9

wait(.1)

Player.PlayerGui.ScreenGui.Frame.BackgroundTransparency = 1

wait(0.1)

end

end)

and theres the example: https://www.youtube.com/watch?v=q0ya-C17UCg&feature=youtu.be (at 0:16)

I think the game repeats the script many times on something if a player touches the part, or i dont know. How can I fix this?

0
ur vid is not available Gameplayer365247v2 1055 — 5y
0
I Fixed it, sorry. User#27142 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You maybe need a debounce, it is used like that :

local debounce = false
local Part = script.Parent

Part.Touched:connect(function(HIT)
    if not debounce then debounce = true
            --add your code here
        wait(3)--you can choose the time btw
        debounce = false
    end
end)
0
I didn't put the part when you check if the things who touch the part is an humanoid, I forgot ^^ Louix27626 83 — 5y
0
how to make it? User#27142 0 — 5y
0
it's in your script already it's : local H = "HIT.Parent:FindFirstChild(“Humanoid”) if H then" at the beginning Louix27626 83 — 5y
Ad

Answer this question