Need help with PlayerGui

Hello,
So i’ve been making a script that can also give the player some errors like; “You can’t buy more of this item”. The thing is that I need the PlayerGui to have that error to appear. I tried to do that but I failed.

Here’s the script;

local tv = game.Workspace:WaitForChild("OldTvClone")
local package = game.Workspace:WaitForChild("OldTvPackage")

if tv and package then
	local oldtvtOOmuch = game.Workspace:WaitForChild("OldTvClone")
	oldtvtOOmuch:Destroy()
	local player = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
	
	player.ErrorGui.ErrorLabel.TweenScript.Disabled = false
	wait(10)
	
	
	script.Disabled = true
	wait(3)
	script.Disabled = false
	script.Disabled = true
else
	warn("warning")
end


1 Like

What error are you getting in output?

That’s unneeded, just use

local player = game.Players.LocalPlayer.PlayerGui
2 Likes

Its telling this error if I do that;

local player = game.Players.LocalPlayer:WaitForChild("PlayerGui")

Now this error;

I think that the script needs to know what the player is. Is that correct?

Hm, I don’t know what’s happening. If it’s a LocalScript, it should know what the LocalPlayer is.

Its not a local script. So what do I do if its a normal script?

Oh, Surround it in a PlayerEntered event.

With

blahblahcode:Connect(function(player))

end)

But its not a function so yea, what should I do now or can I make a function without making it that it
doesn’t do what I want it to do?

Players.PlayerAdded:Connect(function(player)
print ("3")
end)

Do I need to have it like this so it wont affect anything?

local tv = game.Workspace:WaitForChild("OldTvClone")
local package = game.Workspace:WaitForChild("OldTvPackage")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	print(3)
	
end)

if tv and package then
	local oldtvtOOmuch = game.Workspace:WaitForChild("OldTvClone")
	oldtvtOOmuch:Destroy()

	
	local player = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	
	player.ErrorGui.ErrorLabel.TweenScript.Disabled = false
	wait(10)
	
	
	script.Disabled = true
	wait(3)
	script.Disabled = false
	script.Disabled = true
else
	warn("!!WARNING!!")
	
end

If I do that just tried it, it gives an error;

Only LocalScript’s can access LocalPlayer, you’ll need to use a remote or put your code into a LocalScript.

2 Likes

Can you show me how please?? Cause I really want that my game is good enough.

Is there a reason why you are not using this in a local script? If you use a local script, and fire a remote to the server, maybe that would work.

No, there’s no way I can use a localscript for that cause this script runs in a other script and thats server sided too. So idk how I can make that happen.

How is the script activated (if it is connected to something or that activates it) or where is it placed (if it is cloned)?