Local Script - local ReplicatedStorage = game:GetService("ReplicatedStorage")
local spawnButton = script.Parent
local spawnBlockEvent = ReplicatedStorage:WaitForChild("SpawnBlockEvent")
local isSpawned = false
spawnButton.MouseButton1Click:Connect(function()
if isSpawned then
spawnBlockEvent:FireServer("despawn")
spawnButton.Text = "Spawn Part"
else
spawnBlockEvent:FireServer("spawn")
spawnButton.Text = "De-spawn Part"
end
isSpawned = not isSpawned
end)
Server Script - https://pastebin.com/Z8r4cnU7