So, I have a surfaceGui inside of a folder in starterGui, but I want to add a button to that through the script, but since you can’t simply put it into starterGui you have to use playerGui. I have tried fireAllClients and for loops but other plrs can’t see it, any suggestions?
My code is:
local nameLabel = script.Parent:WaitForChild("NamePart"):WaitForChild("NameGui"):WaitForChild("NameLabel")
nameLabel.Text = "Unclaimed!"
--local itemsScroller = script.Parent:WaitForChild("ItemsPart"):WaitForChild("ItemsGui"):WaitForChild("ItemsScroller")
local gamesScroller = script.Parent:WaitForChild("GamesPart"):WaitForChild("GamesGui"):WaitForChild("GamesScroller")
local proximityPrompt = Instance.new("ProximityPrompt", script.Parent.NamePart)
proximityPrompt.HoldDuration = 0.7
proximityPrompt.ActionText = "Hold 'F' to Claim!"
proximityPrompt.UIOffset = Vector2.new(0, 2)
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.F
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.Name = "StandProximityPrompt"
proximityPrompt.Enabled = true
local ConfigurePrompt = Instance.new("ProximityPrompt", script.Parent.ConfigurePart)
ConfigurePrompt.HoldDuration = 0.7
ConfigurePrompt.ActionText = "Hold 'F' to configure stand!"
ConfigurePrompt.KeyboardKeyCode = Enum.KeyCode.F
ConfigurePrompt.UIOffset = Vector2.new(0, 2)
ConfigurePrompt.RequiresLineOfSight = false
ConfigurePrompt.Enabled = false
ConfigurePrompt.Name = "ConfigureProximityPrompt"
local http = game:GetService("HttpService")
local url = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="
proximityPrompt.Triggered:Connect(function(plr)
if plr:FindFirstChild("OwnsStand").Value == false then
local data = http:JSONDecode(http:GetAsync(url .. plr.Name)).data
--local itemsScroller = plr.PlayerGui.ItemSurfaceGuis.ItemsGui.ItemsScroller
if data then
plr:FindFirstChild("OwnsStand").Value = true
script.Parent.Owner.Value = plr.Name
plr:FindFirstChild("StandNumber").Value = script.Parent.Name
game.ReplicatedStorage.RemoteEvent:FireClient(plr)
nameLabel.Text = plr.Name .. "'s Stand"
proximityPrompt.Enabled = false
ConfigurePrompt.Enabled = true
table.sort(data,
function(a,b)
return a.price < b.price
end
)
for i, item in pairs(data) do
local newButton = script.DonateButton:Clone()
--local newClickdetecterPart = script.Parent.ItemsPart.Button:Clone()
newButton.Text = item.price .. "R$"
local id = Instance.new("IntValue", newButton)
id.Value = item.id
local fireId = id.Value
game.ReplicatedStorage.PromptPurchaseEvent:FireClient(plr, fireId)
newButton.Parent = itemsScroller
itemsScroller.CanvasSize = UDim2.new(0, itemsScroller.UIListLayout.AbsoluteContentSize.X, 0, 0)
end
game.Players.PlayerRemoving:Connect(function(plrLeaving)
if plr == plrLeaving then
nameLabel.Text = "Unclaimed!"
proximityPrompt.Enabled = true
script.Parent.Owner.Value = ""
for i, child in pairs(itemsScroller:GetChildren()) do
if child:IsA("TextButton") then child:Destroy() end
end
end
end)
end
end
end)
ConfigurePrompt.Triggered:Connect(function(plr)
if plr.Name == script.Parent.Owner.Value then
game.ReplicatedStorage.ShowGuiEvent:FireClient(plr)
end
end)
game.ReplicatedStorage.UnclaimEvent.OnServerEvent:Connect(function(plr)
local num = plr:FindFirstChild("StandNumber").Value
game.Workspace:FindFirstChild(num).NamePart.NameGui.NameLabel.Text = "Unclaimed!"
game.Workspace:FindFirstChild(num).NamePart.StandProximityPrompt.Enabled = true
game.Workspace:FindFirstChild(num).ConfigurePart.ConfigureProximityPrompt.Enabled = false
script.Parent.Owner.Value = ""
plr:FindFirstChild("OwnsStand").Value = false
for i, child in pairs(game.Workspace:FindFirstChild(num).ItemsPart.ItemsGui.ItemsScroller:GetChildren()) do
if child:IsA("TextButton") then child:Destroy() end
end
for i, child in pairs(game.Workspace:FindFirstChild(num).GamesPart.GamesGui.GamesScroller:GetChildren()) do
if child:IsA("TextButton") then child:Destroy() end
end
end)```