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

Why does my UI not activate for anyone else but me? (Solved)

Asked by
ede2355 22
4 years ago
Edited 3 years ago

So I'm trying to make a UI for someone, but I've encountered a problem, when I activate the UI which uses the key M it works perfectly but when someone else tries it, it doesn't work. I've tried cloning the UI to playerGui but it only worked for me and no one else, I have tried looking at so many articles but to no avail. I was hoping someone could help me here.

Here is some of my code.

--Local Script Inside of StarterGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GUI = ReplicatedStorage.MainMenu
local player = game.Players.LocalPlayer

player.CharacterAdded:Connect(function()
    GUI:Clone().Parent = player.PlayerGui
end)
--Script to open the menu that is in Replicated Storage along with the UI
local frame = script.Parent.Parent.Frame
local uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(inst)
    if inst.KeyCode == Enum.KeyCode.M then
    frame.Visible = true
end 
end)

I just can't seem to find a fix for this, I would appreciate any feedback or help!

0
I mean why would you put it in ReplicatedStorage when everyone will have it straight away? Put in PlayerGui. 6zk8 95 — 4y
0
Because nothing else worked for me before, so I decided to clone it, no one I mean literally no one has the GUI except me, for some reason it only clones it for me. ede2355 22 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

If you want to continue using this method you would need to call a PlayerAdded event. Your script currently looks like:

--Local Script Inside of StarterGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GUI = ReplicatedStorage.MainMenu
local player = game.Players.LocalPlayer

player.CharacterAdded:Connect(function()
    GUI:Clone().Parent = player.PlayerGui
end)

You will want to move the script to the ServerScriptService (make sure to make it a server script, not a local script). Then, you want to change your script to this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local gui = replicatedStorage:WaitForChild("MainMenu")

game.Players.PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function(char)
          gui:Clone().Parent = player.PlayerGui
     end)
end)

Theoretically, this should fix your problem, but if it doesn't please tell me, whether it is by replying to this answer or by messaging me via ROBLOX. If you message me via ROBLOX, I unfortunately won't be able to reply, but I will read your message.

0
I put a server script into ServerScriptService and tried your version of the script out, but yet again it only works for me but nobody else. ede2355 22 — 4y
Ad

Answer this question