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!
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.