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

Crafting System appears for everyone?

Asked by 8 years ago

I have made a simple crafting system, but there is one problem. When I hit the keybind, it opens the GUI for all the players online. I have searched everywhere for this slight bug but nothing comes up. Here's the current code I have.

game:GetService("UserInputService").InputBegan:connect(function(g, y)
    if g.KeyCode == Enum.KeyCode.E then
        if not script.Parent.Parent:IsA("StarterGui") then
            script.Parent.ScrollingFrame.Visible = not script.Parent.ScrollingFrame.Visible
        end
    end
end)

Does anyone have ideas?

Thanks in advance, Iplaydev

1 answer

Log in to vote
0
Answered by
Cuvette 246 Moderation Voter
8 years ago

Find the user who pressed the key and search in their PlayerGui to change the Visibility of the frame.

That obviously won't work yet unless you find out which player pressed the key first.

Player = KeyPressedE.Name -- Find Player who pressed key (The KeyPressedE var won't work it's just an example)
-- Just a simple player variable, You will need to find out the name of the player who pressed the key first

Frame = game.Players[Player].PlayerGui.ScreenGui.ScrollingFrame
-- Find the Frame of the player who pressed the key.

Frame.Visible = not Frame.Visible
-- Keeps you from writing out the same lines again and again.
Ad

Answer this question