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

how can i make a fading dialog when a part is touched?

Asked by
omorizz 50
2 years ago

im trying to make a dialog/text pop up once you press a part, i have a semi-working script for this but it’s a horrible script (i found it on a youtube video since i cant script by myself!) i need help with a script that makes it fade in, stays for a few seconds, then fades out. i also need this script to only happen once, once the part is pressed and only appear for the player that pressed it.

game.Workspace.Trigger.Touched:Connect(function(hit)
    if hit and hit.Parent then
        local debounce = true
        script.Parent.Visible = true
        script.Parent.TextTransparency = 1
        wait(0.025)
        script.Parent.TextTransparency = 0.9
        wait(0.025)
        script.Parent.TextTransparency = 0.8
        wait(0.025)
        script.Parent.TextTransparency = 0.7
        wait(0.025)
        script.Parent.TextTransparency = 0.6
        wait(0.025)
        script.Parent.TextTransparency = 0.5
        wait(0.025)
        script.Parent.TextTransparency = 0.4
        wait(0.025)
        script.Parent.TextTransparency = 0.3
        wait(0.025)
        script.Parent.TextTransparency = 0.2
        wait(0.025)
        script.Parent.TextTransparency = 0.1
        wait(0.025)
        script.Parent.TextTransparency = 0
        wait(2)
        script.Parent.TextTransparency = 0
        wait(0.025)
        script.Parent.TextTransparency = 0.1
        wait(0.025)
        script.Parent.TextTransparency = 0.2
        wait(0.025)
        script.Parent.TextTransparency = 0.3
        wait(0.025)
        script.Parent.TextTransparency = 0.4
        wait(0.025)
        script.Parent.TextTransparency = 0.5
        wait(0.025)
        script.Parent.TextTransparency = 0.6
        wait(0.025)
        script.Parent.TextTransparency = 0.7
        wait(0.025)
        script.Parent.TextTransparency = 0.8
        wait(0.025)
        script.Parent.TextTransparency = 0.9
        wait(0.025)
        script.Parent.TextTransparency = 1
        wait(0.025)
        script.Parent.Visible = false
        local debounce = false
    end
end)

this is the script i currently have (it's hideous, i know) but i can't make it only happen once

2 answers

Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
2 years ago
Edited 2 years ago

Use TweenService

local TS = game:GetService("TweenService")
local Label = script.Parent
local Delay = 0.025
workspace:WaitForChild("Trigger").Touched:Connect(function(HitPart)
    if HitPart then
        local Tween = TS:Create(Label,TweenInfo.new(Delay),{TextTransparency = 1})
        Tween:Play()
        Tween.Completed:Wait()
        wait(2)
        local Tween = TS:Create(Label,TweenInfo.new(Delay),{TextTransparency = 0})
        Tween:Play()
    end
end)
0
where do i put this script? the frame / text or the trigger part? (sry im a noob lol) omorizz 50 — 2y
0
this won't work. you'd need to do a different KIND of tween. Antelear 185 — 2y
0
(he also meant TextTransparency, using just Transparency won't run) Antelear 185 — 2y
0
oh ok 3F1VE 257 — 2y
0
@omorizz the text 3F1VE 257 — 2y
Ad
Log in to vote
0
Answered by
Antelear 185
2 years ago
Edited 2 years ago

Is it a NORMAL script (server sided)? Is it a LOCAL script (client sided)?

if it's a NORMAL one, then delete it. If it's a LOCAL one, and you have it inside of a text LABEL, then please do the following:

local debounce = false -- just making the debounce variable and giving it the TRUE value, does not make it cooldown.

local Part = workspace.Trigger -- don't do game.Workspace, just workspace. It will work the same.. (also use a lowercase w not uppercase W).
local TextLabel = script.Parent -- assuming it's a TextLabel..

Part.Touched:Connect(function()
    if debounce then return end -- if db is true then stop the script here.

    debounce = true -- if it ISN'T false, then continue the script.
    while TextLabel.TextTransparency>0 do -- if transparency is OVER 0, continue running.
        task.wait(0.025)
        TextLabel.TextTransparency-=0.1
    end
    task.wait(2) -- how long it will be on the screen for:

    while TextLabel.TextTransparency<1 do -- if transparency is UNDER 0, continue running.
        TextLabel.TextTransparency+=0.1
    end
    debounce = false
end) -- end function here.

By setting it to true, and if you touch the part again while it IS true, it will stop it from running as it's already true and not false.

The while loops will ONLY run when the condition is still true. So if the transparency was still over 0, it will continue running, bla bla bla.

I hope this helped! <3

0
oh yeah, += and -= means adding/taking away from an existing value <3 Antelear 185 — 2y

Answer this question