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

Is it possible to present a ScreenGUI upon entering an area with this script base?

Asked by 4 years ago

I recently followed a tutorial on the scripting of specific zones to play specific audios within the workspace, but now I want the transition between zones to be followed by a ScreenGUI presenting the area's title.

local AZworkspace = game.workspace:WaitForChild("AudioZones")

local Found = false

while wait (0.1) do

    for i, v in pairs (AZworkspace:GetChildren()) do

        Found = false
        local zone = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))

        local parts = game.workspace:FindPartsInRegion3WithWhiteList(zone, game.Players.LocalPlayer.Character:GetDescendants())

        for _, part in pairs(parts) do
            if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
                Found = true
                break
            else
                Found = false
            end
        end

        if Found == true then
            if script.Parent.AudioZones[v.Name].IsPlaying == false then
                script.Parent.AudioZones[v.Name]:Play()
                break
            end
        else
            script.Parent.AudioZones[v.Name]:Stop()
        end

    end
end

In the workspace, I have a folder titled AudioZones containing four parts titled Zone1, Zone2, and so on.

In the StarterGUI, I have pretty much the same thing -- a folder titled AudioZones containing four sounds titled Zone1, Zone2, and so on -- the script is here as well.

Is it possible for me to adjust the script in a way to present a ScreenGUI instead of audio upon entering the zone?

I know the answer is probably somewhere around the lines of yes, but if that's the case -- is it possible for the ScreenGUI to slide on and off the screen in a single swoop? I don't want it to be a function that makes the player have to click off of it -- I want it to simply come and go.

2 answers

Log in to vote
0
Answered by 4 years ago
local Player = game:GetService("Players").LocalPlayer 

--<< local Character = Player.Character or Player.CharacterAdded:Wait() --<< Best Definition Of Character

local Frame = script.Parent

--<< change "script.Parent.AudioZones[v.Name]:Play()" to "Frame.Visible = true"
--<< change "script.Parent.AudioZones[v.Name]:Stop()" to "Frame.Visible = false"

--<< Or:

if Found then
    Frame.Visible = true
else
    Frame.Visible = false
end
Ad
Log in to vote
0
Answered by 4 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

~~~~~~~~~~~~~~~~~ --<-- I do not know... -->--

~~~~~~~~~~~~~~~~~

Answer this question