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

Intro script in a gui malfunctioning, what should i do?

Asked by 5 years ago

I was making a intro script for my gui, but it doesn't work for some reason. It maybe a common error which i'm too stupid to realize, i putted a print, i tried local and regular scripts but it doesn't work. Why?

game.Players.PlayerAdded:Connect(function(player)
    print("xd")
    player.PlayerGui.Intro.IntroMusic:Play()
    wait(3)
    script.Parent.TextLabel.Visible = false
player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1
player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1
player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1
player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1
player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1
end) 

0
use a for loop User#23365 30 — 5y
0
Use local scripts for screen guis. LoganboyInCO 150 — 5y

1 answer

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

server

if your doing this on the server, you cannot access GUI objects inside a player's PlayerGui. instead use a remote event so the client can make the BackgroundTransparency fade. also use a for loop to make your code shorter and more compact.

--server

local remote = game.ReplicatedStorage.RemoteEvent -- maybe this was the remote

game.Players.PlayerAdded:Connect(function(player)
    print("xd")
    remote:FireClient(player, "fadeGui") -- fire to the client that joined
end)

client:

--local script inside the GUI

local remote = game.ReplicatedStorage.RemoteEvent
local intro = script.Parent.Parent

remote.OnClientEvent:Connect(function(fadeGui)
    if fadeGui == "fadeGui" then
        intro.IntroMusic:Play()

        intro.Stopped:Wait() -- wait till the sound stopped playing

        script.Parent.TextLabel.Visible = false

        for i = 1,0,-.1 do
            intro.Frame.BackgroundTransparency = i -- use the value to set the transparency
            wait()
        end
    end
end)
0
Ill try that. User#22722 20 — 5y
0
Works, i just had to tweak it a bit. It also helped me learn a bit about remote events. User#22722 20 — 5y
Ad

Answer this question