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.
OmqFroko
(OmqFroko)
August 14, 2022, 5:27pm
#23
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
Surface GUIs work with local scripts when the Surface GUI is in StarterGui with its Adornee set to the specific part. However, when Surface GUIs are in the workspace, parented to the part, then you have to use server scripts.
Try this, and you can use a local script to control it and define the plr or have it fire a remote.
OmqFroko
(OmqFroko)
August 14, 2022, 5:29pm
#26
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
Tell me if it works or not, I hope that helped!
OmqFroko
(OmqFroko)
August 14, 2022, 5:38pm
#30
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.
OmqFroko
(OmqFroko)
August 14, 2022, 5:41pm
#32
So now, the script sees the players and both of the teams.
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?
OmqFroko
(OmqFroko)
August 14, 2022, 5:44pm
#34
I putted the whole surfacegui adornee on the place it has before.
So where is the boolean value??
OmqFroko
(OmqFroko)
August 14, 2022, 5:45pm
#37
the bool? the bool is inside the model
Okay, so you need to redefine the bool value because if it’s in the workspace then that wouldn’t work.
OmqFroko
(OmqFroko)
August 14, 2022, 5:46pm
#39
Alright, so put it in the gui aswell.
No, because you wouldn’t be able to see it. To define it you’ll either have to do:
local bool = game.Workspace.GeneradorS1.Blackout