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

How do I make a fading text appears in a certain time?

Asked by 3 years ago

I am trying to make a fading text appears only in the end of my game so I made a local script inside of the text that would make It appear and fade away so then I disabled It and wrote a code that would enable the local script only when the code runs so then It would appear only in a certain time so I wrote this in my main script (It is in server script service)

local player = game.Players.LocalPlayer local PlayerGui = player.PlayerGui local fadingText = playerGui.Transition.outside local fadingTextScript = fadingText.LocalScript fadingTextScript.Disabled = false

I keep getting the Error "ServerScriptService.MainScript:1474: attempt to Index nil with 'PlayerGui'"

It says it dont work at "local PlayerGui = player.PlayerGui"

I dont know what I do to make the text appears and fade away in a certain time because i am not so good at scripting can anyone help me?

1 answer

Log in to vote
2
Answered by 3 years ago

The problem with this is that you cannot access the playerGui from the server. Which means you will have to use a remoteEvent from Server to Client, and instead of enabling the localscript, you would fire the remoteEvent to the client. On the localscript, you would listen for the remoteEvent to be fired, and the text would fade.

First of all, you have to add a remoteEvent inside of replicated storage, so that both the server and client can access it (server and client = script and localscript)

Second, this is what you would add inside the script.

local remoteEvent = game.ReplicatedStorage:WaitForChild("NameOfRemoteEvent") --access the remote event, change the name to what you named it
remoteEvent:FireClient(player) -- you have to have access to the player that has finished the game

In the localscript

local player = game.Players.LocalPlayer
local remoteEvent = game.ReplicatedStorage:WaitForChild("NameOfRemoteEvent") --access the remote event, change the name to what you named it
remoteEvent.OnClientEvent:Connect(function()
    -- do all of the fading text here
end)

Hope this helps

0
So it is a story game so all of the players that are still on the game are alive and finished it so how I make that this script runs for all players and not just for the player that "finished the game"? BrasileiroConstrutor 27 — 3y
0
You will have to access all the players, make a for loop and use FireClient(player) on them. Here is an example https://dpaste.org/W0Os mariohead13 129 — 3y
Ad

Answer this question