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

How do you make a Gui only can be seen the person that is in the group see it?

Asked by
dog6779 25
5 years ago
Edited 5 years ago

Hello, my name is dog6779. This is my first time scripting.

Problem

I trying to make a Gui where it pops up but ONLY GROUP MEMBERS can only see it. But I want it where it does its animation. By the way, it is in a folder which I would be organized most of the time. As you can see the main:TweenPosition(UDim2.new(0.284, 0,0.201, 0), "Out","Bounce",0.5) that a animation to make where it get clicked then it pops up.

Script

game.Workspace.Computers.Computer1.Screen.ClickDetector.MouseClick:Connect(function(playerInGroup)
    game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankinGroup(4222666) == 0 then
            if open == false then
            Player.PlayerGui.Main.Frame.Visible = false
            main:TweenPosition(UDim2.new(0.284, 0,0.201, 0), "Out","Bounce",0.5)
            if close == true then
                Player.PlayerGui.Main.Frame.Visible = true
                main:TweenPosition(UDim2.new(0.284, 0, 1, 0), "Out","Bounce",0.5)
            end
        end)
    end
end)
print("Frame Open!")

Please tell me what I do wrong?

0
You’re modifying the PlayerGui on the server. That’s what’s wrong. User#19524 175 — 5y
0
But how do I fix it? dog6779 25 — 5y
0
Edited. User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

There is lots of unnecessary code, especially the MouseClick inside the PlayerAdded event. Not necessary. Also, you’re trying to modify PlayerGui from the server, which is not good. Fire a RemoteEvent to the client if they are in the group.

-- Server Script, inside Workspace.Computers.Computer1.Screen

local rep = game:GetService"ReplicatedStorage"
local showGui = rep:WaitForChild"ShowGui"
--RemoteEvent under ReplicatedStorage^ 

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if plr:IsInGroup(4222666) then
        -- instead of checking the rank, check if they’re in the group
        showGui:FireClient(plr)
    end
end)

This is the local code.

--LocalScript, under PlayerGui.Main.Frame

local rep = game:GetService"ReplicatedStorage"
local showGui = rep:WaitForChild"ShowGui"
local out = Enum.EasingDirection.Out
local bounce = Enum.EasingStyle.Bounce
--Use Enum’s instead of strings

showGui.OnClientEvent:Connect(function()
    script.Parent.Visible = true

    script.Parent:TweenPosition(
        UDim2.new(.284, 0, 1, 0),
        out,
        bounce,
        0.5
)

end)
0
Ah, now I see. dog6779 25 — 5y
0
By the way on line 13 on the second script I see a error the one with the ; dog6779 25 — 5y
0
There is no error? User#19524 175 — 5y
0
Here I will send a screen shot. dog6779 25 — 5y
View all comments (4 more)
0
he made a typo, use the new code. masterblokz 58 — 5y
0
Somehow I tryed to get it to work but it does not work for no reason. dog6779 25 — 5y
Ad

Answer this question