What do you want to achieve?
When the player triggers the ProximityPrompt, it fires the event from the ServerScript to the Client.
What is the issue?
I get this error:
Workspace.Model.DoorC1.Prox.ProximityPrompt.Script:8: attempt to index nil with 'PlayerGui'
What solutions have you tried so far?
I’ve tried using
local player = game.Players.LocalPlayer
but to the best of my knowledge, that only works for LocalScripts, not ServerScripts.
ProximityPrompt ServerScript:
script.Parent.Triggered:Connect(function(prompt)
script.Sound:Play()
local character = prompt.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local playergui = player["PlayerGui"]
local textbox = playergui.Fade.Transition
--textbox.Text = text
print("fade triggered")
textbox.Fader:FireClient(player)
end)
You can not access LocalPlayer unless you are using a LocalScript (or ModuleScript accessed by a LocalScript).
Luckily, the Triggered event already passes the player, so you can change your code to this:
script.Parent.Triggered:Connect(function(player)
script.Sound:Play()
local character = prompt.Parent
local playergui = player["PlayerGui"]
local textbox = playergui.Fade.Transition
--textbox.Text = text
print("fade triggered")
textbox.Fader:FireClient(player)
end)