PlayerGui calling issue

Hello, so today I’m writing because I keep getting this error when I’m calling the PlayerGui.image

Here’s the code I’m using.

local PlayerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
script.ScreenGui.Parent = PlayerGui
local ScreenGui = PlayerGui.ScreenGui
wait(.05)
local Image = ScreenGui.MainFrame.GroupImage
game:IsLoaded()
Image:TweenPosition(UDim2.new({0.242, 0},{0.076, 0}), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .3, true)
game.ReplicatedFirst:RemoveDefaultLoadingScreen()

if not game:IsLoaded() then
	game.Loaded:Wait()
end

wait(5)
Image:TweenPosition(UDim2.new({2, 0},{0.076, 0}), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, .3, true)
wait(1)
script.ScreenGui:Destroy()

the problem is you are trying to get the LocalPlayer in a Server Script which runs on the server so there is no “LocalPlayer”


do all UI stuff on the client (Local Scripts)

1 Like

You cannot call a LocalPlayer from a server script. You can only use LocalPlayer in a local script. Not a Server Script.

You’ll need to run your script on the client, to do this simply change your script to a localscript and put it into StarterPlayerScripts.

1 Like