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

does anyone know how to make a gui only show for a certain player? [closed]

Asked by 3 years ago
Edited 3 years ago

i was playing with my friend and he got to the gui part and it showed up for him and me aswell. so i need to figure out how to make it so it only shows for the player that triggered the gui


workspace.WishHimAGoodBirthday.ClickDetector.MouseClick:Connect(function() script.Parent.TextTransparency = 0.9 wait(.03) script.Parent.TextTransparency = 0.8 wait(.03) script.Parent.TextTransparency = 0.7 wait(.03) script.Parent.TextTransparency = 0.6 wait(.03) script.Parent.TextTransparency = 0.5 wait(.03) script.Parent.TextTransparency = 0.4 wait(.03) script.Parent.TextTransparency = 0.3 wait(.03) script.Parent.TextTransparency = 0.2 wait(.03) script.Parent.TextTransparency = 0.1 wait(.03) script.Parent.TextTransparency = 0.0 end)

Marked as Duplicate by killerbrenden, Cynical_Innovation, IAmNotTheReal_MePipe, and TaxesArentAwesome

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You're going to need 2 scripts and a RemoteEvent (put the RemoteEvent in the ReplicatedStorage)

Server script (put this in the server script service)

local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local playerId = 000000 -- make this the UserId of the player that you want to see the GUI

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        if player.UserId == playerId then
            event:FireClient(player)
        end
    end)
end)

Local script (put this in the TextLabel or whatever is inside the ScreenGui)

-- localscript
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local gui = script.Parent.Parent -- the ScreenGui object.
gui.Enabled = false -- make everything that is part of ScreenGui invisible.

event.OnClientEvent:Connect(function()
    gui.Enabled = true
end)

Make sure to change these variables to actually match what they are in your game (playerId, gui location, etc).

Hope this helps!

EDIT: In response to you're comment:

Server script (ServerScriptService):

local endPart = workspace:WaitForChild("EndPart")
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

endPart.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        event:FireClient(player)
    end
end)

The LocalScript should stay as it is.

0
i am trying to make it so if one person gets to the end then they see the gui not the other players and if i do it by user id then that one use id is going to be the only person that is able to see the gui diggerbear1 32 — 3y
0
Hi, I just edited the answer so hopefully it helps you. DaysWeeksAndMonths 90 — 3y
Ad