Is there anything wrong with my script?
i cant figure out why it don’t work
wait(1)
local num = math.random(1,10)
local Notif = game.ServerStorage.Notif2
local clone = Notif:Clone()
local Player = game:GetService("Players").LocalPlayer
print(num)
if num == 4 then
clone.Parent = Player.PlayerGui
end
end
Heres the output error:
Can’t access the ServerStorage
if this is in a LocalScript
, put it inside ReplicatedStorage
instead so that it’s visible across both sides
omg that would make sense becuase in the output i would get an error saying something about not having acsess to “notif2”
Definitely tell us the errors next time please.
look at the edit, i uploaded a output message
i have a output error image, in the edit
JayO_X
(fakefriends)
May 16, 2021, 5:22am
#7
Is the script a local script or server script?
i think its a server script, its not a local script and also the script is in serverscriptservice
JostosYT
(JostosUS)
May 16, 2021, 5:23am
#9
Maybe you should reference StarterGui
JayO_X
(fakefriends)
May 16, 2021, 5:23am
#10
You cant get the local player from the server make sure the script is a local script
yeah i would do that but i want this line of code to happen to all players
JayO_X
(fakefriends)
May 16, 2021, 5:28am
#12
Remove the local player from your script
JayO_X
(fakefriends)
May 16, 2021, 5:31am
#13
Try to find a way to implement this into your code
for index, player in pairs(game.Players:GetPlayers()) do
if player then
wait(1)
local num = math.random(1, 10)
local Notif = game.ServerStorage.Notif2
local clone = Notif:Clone()
print(num)
if num == 4 then
clone.Parent = player:WaitForChild("PlayerGui")
end
end
end
JayO_X:
for _, player in next, game.Players:GetPlayers() do
if player then
wait(1)
local num = math.random(1, 10)
local Notif = game.ServerStorage.Notif2
local clone = Notif:Clone()
print(num)
if num == 4 then
clone.Parent = player:WaitForChild("PlayerGui")
end
end
end
does this use tables? i dont know how that top part works, lol sry but if you could explain what that does then i would be happy
JayO_X
(fakefriends)
May 16, 2021, 5:35am
#15
game.Players:GetPlayers() return a table of the players in the game. the top part is looping through the players in the game
if player then
local notif = game.ServerStorage.Notif2
local clone = notif:Clone()
clone.Parent = player.PlayerGui
end
end
Would i be doing this the right way?
JayO_X
(fakefriends)
May 16, 2021, 5:46am
#17
Yes if it doesn’t work can you show me more of the script
It seems that this script doesnt work either (the one i quoted)
JayO_X
(fakefriends)
May 16, 2021, 5:50am
#19
is that your entire script? or are you showing a portion of it
well im trying to run that as a test script but yeah thats what i got right now