Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

gui wont popup when i touch a part?

Asked by 5 years ago
Edited 5 years ago

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)
0
The server cannot access PlayerGui's descendants unless said descendants were placed by the server. You will want to handle Touched on the client or use remote events. And connect is deprecated, switch to Connect. User#19524 175 — 5y
0
try using remote events to make the gui pop up the local side theking48989987 2147 — 5y
0
i updated Prbo1201 56 — 5y

3 answers

Log in to vote
0
Answered by
green271 635 Moderation Voter
5 years ago

Some things to note:

Server Scripts and PlayerGui

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 vs Connect

connect is deprecated. It is not recommend to use deprecated for many reasons, such as:

  • Deprecated items may be removed at any time
  • Items are usually deprecated because there is a better way of doing something
  • It may be outdated
  • It is bad practice

You should instead use Connect.

Ad
Log in to vote
0
Answered by 5 years ago

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)
Log in to vote
0
Answered by 5 years ago

I guess you did something wrong in it,or you removed the Part.

Answer this question