Hi there. I was working on my code Notiff (COMING SOON) and I got this error:
Here’s my code:
Any help is appreciated!
EDIT: It"s a ModuleScript
Hi there. I was working on my code Notiff (COMING SOON) and I got this error:
Here’s my code:
Any help is appreciated!
EDIT: It"s a ModuleScript
Try this
local icon = {}
local format = game:GetService('ReplicatedStorage'):WaitForChild('Format')
local themes = script.Parent.Parent:WaitForChild('Themes')
function icon:MakeNewNotiff()
local player = game:GetService('Players').LocalPlayer
local playerGui = player:WaitForChild('PlayerGui')
local nf = format:Clone()
wait(0.1)
nf.Parent = playerGui
end
I put it in, but then this happened:
I believe in order to use LocalPlayer it has to be in a Local Script
Yeah. Make it a local script or use remotes
It seems you are running client-side code (local code) on the server.
You need to put this code in a localscript and not in a normal script:
local NotiffModule = require(Workspace.Notiff.Scripts.Notiff)
NotiffModule:MakeNewNotiff()
local icons = {}
local format = game.ReplicateStorage.Format
script.Parent.Parent.Themes
function icon:MakeNewNotiff(player)
local nf = format:Clone()
nf.Parent = player.PlayerGui
end
you can’t use the “LocalPlayer” variable in a server script or module script. Use this, and make sure when firing the function to put the “player” argument inside of the function, If you know what I mean
LocalPlayer
is nil because it cannot be indexed by server scripts - you have to use remote events.
Aight so
I used both of your scripts, but now it doesn’t have an error. Nor does the gui show.
My screen:
Code (localscript):
Path:
make another variable. Name it to plr, and then put the player variable inside the function.
Like this:
local notiff = require(workspace.Notiff.Scripts.Notiff)
local plr = game.Players.LocalPlayer
notiff:MakeNewNotiff(plr)
This should work since the localplayer is inside of the localscript.
Any local script does not work in workspace. Instead put it on StarterPlayer>StarterPlayerScript
That’s parenting to the player, not the player gui.
AYY it works! Tysm! 30charlimit