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?
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