Basically, I have a shop GUI that gives you items, when you get given an item it can only be seen by the person holding it. Why?
Howdy!
This is a security feature implemented within the last year where scripts need to abide by FilteringEnabled
rules. This means that the client is cut off entirely from the server, which means that if your client says "this player has a gun", the server won't listen and other players can't see it. In order to go around this, we have to use RemoteEvents
. You can learn more about those here and here.
This is the example that Roblox uses to show how using a RemoteEvent
works (when in terms of client-server communication). Your local script would look like what we have below.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent") createPartEvent:FireServer(BrickColor.Green(), Vector3.new(10, 20, 0))
And your server script would look like what is below.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage) createPartEvent.Name = "CreatePartEvent" local function onCreatePartFired(player, color, position) print(player.Name, "wants to create a part") local newPart = Instance.new("Part") newPart.BrickColor = color newPart.Position = position newPart.Parent = game.Workspace end createPartEvent.OnServerEvent:Connect(onCreatePartFired)
Essentially, you need to use :FireServer()
from the client to tell the server to run the code you want so that EVERYONE can see it.
If this helped you out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I (or someone else) will help you out.