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

How To Make A GUI Show Up For One Character?

Asked by
tanzane 100
9 years ago
    function YouThought()
    wait(1) 
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true
    wait(2)
game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false
    end
game.workspace.Obby3.SIKE.Touched:connect(YouThought)

As you see above, this script is suppose to make a Gui show up when someone touches a certain brick and dies. Well.

This LOCAL SCRIPT works fine but the thing is that whenever someone touches that brick instead of being visible to only that person who touched it, it's visible for everyone in the server and I believe that'd be kind of annoying to see when someone else touches it instead. Anyway, I just wanted to know how to make it where it ONLY shows up for the person who touched it and not everyone.

Oh and, Obby3 is a model....

1 answer

Log in to vote
1
Answered by 9 years ago

Use Players:GetPlayerFromCharacter on the player's model to find the player you want to change the GUI of, like so:

function YouThought(touched)
    local player = game.Players:GetPlayerFromCharacter(touched.Parent)
    if not player then return end

    wait(1) 
    player.PlayerGui.ScreenGui.Frame.Visible = true
    wait(2)
    player.PlayerGui.ScreenGui.Frame.Visible = false
end

game.workspace.Obby3.SIKE.Touched:connect(YouThought)
Ad

Answer this question