script.Parent.Touched:connect(function(HIT) local h = HIT.Parent:FindFirstChild("Humanoid") if h then local Player = game.Players:WaitForChild(HIT.Parent) Player.PlayerGui['Finish GUI'].Frame.Visible = true end end)
Some things to note:
Now that FilteringEnabled
is mandatory, it's restrictions are now in place. One of these is a change to what Server Scripts
can see.
A Server Script
can see the player's PlayerGui
, but cannot edit it's contents. The only exception is if it is parenting an object to it, then it can edit it freely.
How do we get around this? There are a couple ways. You can try putting this script into a LocalScript
, and parenting it to the player's PlayerGui. Or you can use a RemoteEvent
to change the player's gui.
connect
is deprecated. It is not recommend to use deprecated for many reasons, such as:
You should instead use Connect
.
The Answer is Remote Event. What this does is connects the Server
to the Client
, allowing you to use PlayerGui from the Server Side (Sort of). To Do this, first make a Remote Event
in Replicated Storage
, as the Server and Client can both see this. Name it whatever you want, for this example i'll be naming it "TouchedEvent"
There should be a Server Script
(Normal Script) in what you want touched, and a LocalScript
in StarterGui
. Script as followed
Server:
script.Parent.Touched:Connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h then local plr = game.Players:WaitForChild(hit.Parent) game.ReplicatedStorage.TouchedEvent:FireClient(plr) -- Fires RE end end)
Local:
game.ReplicatedStorage.TouchedEvent.OnClientEvent:Connect(function() -- Sees that the event has been fired local plr = game.Players.LocalPlayer plr.PlayerGui['Finish GUI'].Frame.Visible = true end)
I guess you did something wrong in it,or you removed the Part.