I have a buy menu that needs to appear for all players in a region3. Players can buy something and it updates on the gui. Problem is giving the gui to everyone. If I just put the gui in StarterGui and enable it from their PlayerGui when they enter the region, that isn’t going to replicate other’s purchases and their purchases to the StarterGui. I can’t clone it either because that doesn’t update the original GUI, either.
So, I dunno what to do really. How can I give it to all players and still update?
I already have this code:
local Player = game.Players.LocalPlayer
local Lower = game.Workspace.Region3.BlueLower
local Upper = game.Workspace.Region3.BlueUpper
local min = Lower.Position - (0.5 * Lower.Size)
local max = Upper.Position + (0.5 * Upper.Size)
local Region = Region3.new(min, max)
local VisualizePart = false
if VisualizePart then
local Visualize = Instance.new("Part", workspace)
Visualize.Anchored = true
Visualize.Transparency = 0.5
Visualize.Color = Color3.fromRGB(255,0,0)
Visualize.CanCollide = false
Visualize.Size = Region.Size
Visualize.CFrame = Region.CFrame
end
function update(player, IsIn)
if player then
if IsIn == true then
game.ReplicatedStorage.RedBuyMenu.Enabled = true
local appear =game.ReplicatedStorage.RedBuyMenu.RedBuyMenuFrame:TweenPosition(
UDim2.fromScale(0.705, 0.679),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
0.2,
false)
elseif IsIn == false then
local disappear = game.ReplicatedStorage.RedBuyMenu.RedBuyMenuFrame:TweenPosition(
UDim2.fromScale(0.99, 0.679),
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
0.2,
false)
game.ReplicatedStorage.RedBuyMenu.Enabled = false
end
end
end
while true do
wait()
local Parts = game.Workspace:FindPartsInRegion3WithIgnoreList(Region, {Upper, Lower}, math.huge)
local IsIn = false
for i,v in pairs(Parts) do
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
if PlayerCharacter and v.Name == "HumanoidRootPart" and Player.Team == game:GetService("Teams")["Blue"] then
if v.Parent == PlayerCharacter then
IsIn = true
end
end
end
update(Player, IsIn)
end
Like wupf said, you’ll have to use something to display it. You can either have the client display it in the region and have the server check the region if the interface needs to do anything specific that requires security backing it. If you don’t give it to the client before, you’ll have to clone it. There’s a few ways but the general idea is you either have to clone it or have it already given to them. Clients cant share a single interface under their PlayerGui.
Giving it to the client from a Region would require a remote, or the region would need to also be checked on the client and then display the interface that way (assuming it already exists on the client).
The server would have to clone it to the PlayerGui if you wanted to give it to the client from the server.
If you want other players to see the same gui, you need to use remotes to send the changed data each time a change is made.
and everytime the data changes a remote fires to update all copies of the gui?
How do I even update the gui with the remote, wouldn’t I have to systematically check every single thing in the menu (which is huge) or just delete it and replace it
as it currently stands the player clicks a textbutton in the buy menu and the local script gets the input and sends it to a remote to the server to do cash subtraction, tween the icon, clone it to the backpack, etc. What im gonna do now is everytime it happens in the server script i will overwrite every other gui on the server the moment the click happens.
edit: wait that is not gonna update every gui for tweens
You would give the gui to the clients through remote event or make it visible from player gui.
Since Player Gui is on each clients you would have a local script inside the gui that is copied when you give it to them through remote event. That way the gui updates when they themselves click, let’s say a shop button, they get the shop menu while other players don’t.
If your saying how to update each gui on each of clients then probably you would have to use a bunch of remote events
so the menu is in startergui and everyone when they join the game gets a copy of it in their player gui. when a single player clicks to buy anything, the localscript handles the input and sends it to the serverscript in server script service via remote event.
the serverscript then loops through player list for all the players on red or blue team (because red or blue team have different buy menus, let’s just assume the menu is on the red team for now) and for every red team player it will update the gui through their playergui with the new updated info, so everyone sees the tween and new prices, etc.
:'D
.
.
edit: this worked. is very epic. wasnt the common idea and it seemed like a dead end but is probably the best solution