Hi i took your script and altered it.
01 | --serverscript |
02 |
03 | local part = workspace.Part |
04 | local remoteEvent = game.ReplicatedStorage.RemoteEvent |
05 | local gui = game.StarterGui.ScreenGui.Frame |
06 |
07 | part.Touched:Connect( function (objectThatTouchedMe) |
08 | if objectThatTouchedMe.Parent:FindFirstChild( "Humanoid" ) then |
09 | local client = game.Players:GetPlayerFromCharacter(objectThatTouchedMe.Parent) |
10 | gui.Visible = false |
11 | remoteEvent:FireClient(client) |
12 | end |
13 | end ) |
1 | --localscript |
2 |
3 | local remotevent = game.ReplicatedStorage.RemoteEvent |
4 | local gui = game.StarterGui.ScreenGui.Frame |
5 | local function visiblegui () |
6 | print ( "recieved remote call" ) |
7 | end |
8 |
9 | remotevent.OnClientEvent:Connect(visiblegui) |
doesnt work can you tell why?
it prints 'recieved remote call' but the frame doesnt disappear.
defining the frame in StarterGui and changing its visibility does nothing. It makes sense that every player has their own GUI so what I mean is that StarterGui is a container that will copy its descendants and parent them to PlayerGui in the PlayerObject.
So instead of this
1 | local GUI = game.StarterGui.ScreenGui.Frame |
You want to define the PlayerGui and define the Frame from the PlayerGui
1 | local client = game.Players.LocalPlayer |
2 | local GUI = client.PlayerGui.ScreenGui.Frame |
Do this in the LocalScript
So if you look in your explorer and start the game
-Players
1 | [ Player.Name ] |
2 |
3 | PlayerGui |
4 |
5 | ScreenGui |
6 |
7 | Frame |