Why I cant make my script to be only used for certain time?

Hmm, okay one sec lemme test this.

There is no “player” argument on MouseButton1Click

Instead you can get the player by adding this to your script:

local plr = game:GetService("Players").LocalPlayer

then you can get the team by doing this:

button.MouseButton1Click:Connect(function()
	for i,b in pairs(Enemy) do
		if plr.Team.Name == b then
	         --player is on one of the "Enemy" teams
	end
end)

Also make sure that you are using a LocalScript to do this. A regular Script will not work.

It’s a server script, and using a local script for a surface UI isn’t the best.

Already tested with a local script, instead the script, the local script doesnt work neither and doesnt even send a single outputerror.

Then what you should do is create a RemoteEvent in ReplicatedStorage and then create a Script in ServerScriptService that changes the SurfaceGui when the RemoteEvent is fired.

1 Like

Try this, and you can use a local script to control it and define the plr or have it fire a remote.

So making a copy of the gui and put it on the startergui?

So put it into StarterGui and adornee it to the part you want it on. And then you can use a local script to control it. And define the plr as game.Players.LocalPlayer

1 Like

Alright.

1 Like

Tell me if it works or not, I hope that helped!

Good news, there isnt anymore that error.
Bad news, script doesnt work yet but there no errors this time.

Alright, np I’m able to help you fix it. So what about it doesn’t work does it just not do anything at all??
And if so I’d advise you try and use a few prints to figure out what runs and what doesn’t.

So now, the script sees the players and both of the teams.
image
The bool still maintains false so it means the script stopped before the bool turns true

But it just not do anything

Is your boolean defined from where you placed it and is the loading defined?

I putted the whole surfacegui adornee on the place it has before.
image

So where is the boolean value??

image
image

the bool? the bool is inside the model
image

Okay, so you need to redefine the bool value because if it’s in the workspace then that wouldn’t work.

Alright, so put it in the gui aswell.