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 6 years ago

I have a script in a part that is supposed to make it so when any player touches the part it will show the person who touched the part a Gui.

local Part = script.Parent

Part.Touched:connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
            local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
            Player.PlayerGui.finish gui.Frame.Visible = true
    end
end) 


0
server scripts can't access guis from players unless it clones one and gives it to the player hellmatic 1523 — 6y
0
line 7: Player.PlayerGui["finish gui"].Frame.Visible = true Epuuc 74 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

ch0kehold is nearly correct. If you have a space in the instance's .Name, you need to access it like this:

--////Assuming that you're trying to access a Frame that is inside an object named 'Finish GUI'

--//You don't need to assign script.Parent to a variable, as you only use it once
--local Part = script.Parent

--//script.Parent.Touched is the same as Part.Touched, but without the wasted variable
script.Parent.Touched:connect(function(HIT)
    local h = HIT.Parent:FindFirstChild("Humanoid")
    if h then
        local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
        --You put the object name inside square brackets, as a string
        Player.PlayerGui['Finish GUI'].Frame.Visible = true
    end
0
it still won't work for some reason Prbo1201 56 — 6y
0
Can you post a screenshot of your game's hierarchy, so we can see where all your instances are? @Prbol1201 plasmascreen 143 — 6y
0
ok Prbo1201 56 — 6y
0
how do i post it Prbo1201 56 — 6y
View all comments (3 more)
0
Use imgur or a similar service plasmascreen 143 — 6y
0
Put the script inside of the Frame plasmascreen 143 — 6y
Ad
Log in to vote
0
Answered by
format 55
6 years ago
Edited 6 years ago

// thats the line where i think your error is:

Player.PlayerGui.finish gu.Frame.Visible = true

// replace it with that:

 Player.PlayerGui.["finish gui"].Frame.Visible = true   

Answer this question