Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this script not work which uses remote events?

Hi i took your script and altered it.

--serverscript

local part = workspace.Part
local remoteEvent = game.ReplicatedStorage.RemoteEvent
local gui = game.StarterGui.ScreenGui.Frame

part.Touched:Connect(function(objectThatTouchedMe)
	if objectThatTouchedMe.Parent:FindFirstChild("Humanoid") then
		local client = game.Players:GetPlayerFromCharacter(objectThatTouchedMe.Parent)
		gui.Visible = false
		remoteEvent:FireClient(client)
	end
end)

--localscript

local remotevent = game.ReplicatedStorage.RemoteEvent
local gui = game.StarterGui.ScreenGui.Frame
local function visiblegui ()
	print("recieved remote call")
end

remotevent.OnClientEvent:Connect(visiblegui)

doesnt work can you tell why?

it prints 'recieved remote call' but the frame doesnt disappear.

1 answer

✓ Accepted answer

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

local GUI = game.StarterGui.ScreenGui.Frame

You want to define the PlayerGui and define the Frame from the PlayerGui

local client = game.Players.LocalPlayer
local GUI = client.PlayerGui.ScreenGui.Frame

Do this in the LocalScript

So if you look in your explorer and start the game

-Players

[Player.Name]

     PlayerGui

         ScreenGui

               Frame

1 comment

0

Ohh i get it now, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.