local y=EventsFolder:FindFirstChild("\078\111\116\105\102\105\099\097\116\105\111\110")local J=EventsFolder:FindFirstChild("\069\100\105\116\080\108\111\116")local K=game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")local l=script.Parent.Parent.Parent.Parent.SignDescription.SurfaceGui.Frame.OwnerLabel local d=game:GetService("\083\116\097\114\116\101\114\071\117\105")local C=script.Parent.Parent.Parent.Parent.Name local E=d:FindFirstChild("\083\105\103\110\080\114\105\099\101\115")local c=E:WaitForChild(C)local D=c.ScrollingFrame:FindFirstChild("\084\101\109\112\108\097\116\101")function Triggered(K)local d=K.Name if Owner.Value==nil or"\078\111\079\110\101"then if K:FindFirstChild("\079\119\110\101\114")then y:FireClient(K,"\067\108\097\105\109\101\100")else Owner.Value=d l.Text=d.."\'\115 \083\116\097\110\100"y:FireClient(K,true)local C=(game:GetService("\080\108\097\121\101\114\115")):GetUserIdFromNameAsync(d)Bindable:Fire(script.Parent.Parent.Parent.Parent.Name,d,C)l.Parent.MoneyRaised.Text=K.leaderstats.Raised.Value.."\036 \082\097\105\115\101\100"local E=Instance.new("\073\110\116\086\097\108\117\101")E.Value=script.Parent.Parent.Parent.Parent.Name E.Name="\079\119\110\101\114"E.Parent=K J:FireClient(K,script.Parent.Parent.Parent.Parent.Name,true)Prompt.Enabled=false end end end script.Parent.Triggered:Connect(Triggered)local W=game:GetService("\080\108\097\121\101\114\115")local T=EventsFolder:FindFirstChild("\082\101\109\111\118\101\066\117\116\116\111\110\070\114\111\109\067\108\105\101\110\116")W.PlayerRemoving:Connect(function(y)local K=y.Name if K==Owner.Value then T:FireAllClients(script.Parent.Parent.Parent.Parent.Name)Owner.Value="\078\111\079\110\101"J:FireClient(y,script.Parent.Parent.Parent.Parent.Name,false)Prompt.Enabled=true l.Text="\078\111 \079\110\101\'\115 \083\116\097\110\100"script.Parent.Parent.Parent.Parent.SignTitle.SurfaceGui.Frame.SignLabel.Text="\080\076\083 \068\079\078\065\084\069"l.Parent.MoneyRaised.Text="\048\036 \082\097\105\115\101\100"local K=d.SignPrices[script.Parent.Parent.Parent.Parent.Name].ScrollingFrame:GetChildren()for y,J in ipairs(K)do if J:IsA("\070\114\097\109\101")and J.Name~="\084\101\109\112\108\097\116\101"then J:Destroy()end end else return end end)
--local InfoBindable = EventsFolder:FindFirstChild("GetInfo")
--local ToClient = EventsFolder:FindFirstChild("SendButtonToClient")
local Notification = EventsFolder:FindFirstChild("Notification")
local EditPlot = EventsFolder:FindFirstChild("EditPlot")

local MarketPlaceService = game:GetService("MarketplaceService")

local OwnerLabel = script.Parent.Parent.Parent.Parent.SignDescription.SurfaceGui.Frame.OwnerLabel

local StarterGui = game:GetService("StarterGui")
local StandNum = script.Parent.Parent.Parent.Parent.Name

local PriceFolder = StarterGui:FindFirstChild("SignPrices")
local UI = PriceFolder:WaitForChild(StandNum)

local Template = UI.ScrollingFrame:FindFirstChild("Template")

function Triggered(Player)
	local PlayerName = Player.Name

	if Owner.Value == nil or "NoOne" then -- If booth hasn't been claimed
		if Player:FindFirstChild("Owner") then -- If Player has claimed one
			Notification:FireClient(Player, "Claimed") -- Let them know they already own one
		else -- If Player hasn't claimed one
			Owner.Value = PlayerName
			OwnerLabel.Text = PlayerName .. "'s Stand"
			Notification:FireClient(Player, true) -- Claimed

			local UserID = game:GetService("Players"):GetUserIdFromNameAsync(PlayerName)
			Bindable:Fire(script.Parent.Parent.Parent.Parent.Name, PlayerName, UserID)

			-- This should be for giving a player a value
			OwnerLabel.Parent.MoneyRaised.Text = Player.leaderstats.Raised.Value .. "$ Raised"

			local OwnerValue = Instance.new("IntValue")
			OwnerValue.Value = script.Parent.Parent.Parent.Parent.Name -- set int value to booth name
			OwnerValue.Name = "Owner"
			OwnerValue.Parent = Player

			-- Would this be the best way to do this? Yes, absolutely!

			-- We want the editPrompt to ONLY show for the client player.

			EditPlot:FireClient(Player, script.Parent.Parent.Parent.Parent.Name, true)
			Prompt.Enabled = false
		end
	end
end

script.Parent.Triggered:Connect(Triggered)

local Players = game:GetService("Players")
local RemoveButtonsFromClient = EventsFolder:FindFirstChild("RemoveButtonFromClient")

Players.PlayerRemoving:Connect(function(player)
	local plrRemovingName = player.Name
	if plrRemovingName == Owner.Value then
		RemoveButtonsFromClient:FireAllClients(script.Parent.Parent.Parent.Parent.Name)
		Owner.Value = "NoOne"
		EditPlot:FireClient(player, script.Parent.Parent.Parent.Parent.Name, false)
		Prompt.Enabled = true

		OwnerLabel.Text = "No One's Stand"
		script.Parent.Parent.Parent.Parent.SignTitle.SurfaceGui.Frame.SignLabel.Text = "PLS DONATE"
		OwnerLabel.Parent.MoneyRaised.Text = "0$ Raised"

		local Children = StarterGui.SignPrices[script.Parent.Parent.Parent.Parent.Name].ScrollingFrame:GetChildren()
		for _, child in ipairs(Children) do
			if child:IsA("Frame") and child.Name ~= "Template" then
				child:Destroy()
			end
		end
	else
		return -- Not the Owner
	end
end)
