I’m trying to make a building feature but only on the client, I want to avoid people blocking spawn,
I’m also trying to make it wait a while (like 5 seconds) before it fades away and gets deleted
I tried making a Despawn using a “for I = 1, 10” but it stopped running at that point
keep in mind, I’m not a really good scripter
tool = script.Parent
tool.equipped:connect(function()
wait(0.1)
while true do
wait()
if tool.Parent:FindFirstChild("Part") == nil then
--prevent the player blocking themselves by spamming the tool
script.Enabled = false
wait(0.3)
script.Enabled = true
--just basic part making stuff
local Part = Instance.new("Part")
Part.Parent = tool.Parent
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(4, 0.5, 4)
--make the highlight look like a highlight
local highlight = Instance.new("Highlight")
highlight.Parent = Part
highlight.Adornee = Part
highlight.DepthMode = ("Occluded")
highlight.FillColor = Color3.new(0, 0, 255)
end
local Part = tool.Parent:FindFirstChild("Part")
--Basicly this is positioning the Placement highlight
local Root = tool.Parent:WaitForChild("HumanoidRootPart")
local pos = Root.CFrame * CFrame.new(0, -1, -5)
Part.CFrame = pos
end
end)
tool.Unequipped:Connect(function()
local Part = game.Players.LocalPlayer.Character:FindFirstChild("Part")
Part:Destroy()
end)
tool.Activated:Connect(function()
local Part = game.Players.LocalPlayer.Character:FindFirstChild("Part") --just checking if the player already has a Placement highlight
if Part ~= nil then
local high = Part:FindFirstChild("Highlight")
high:Destroy()
Part.Parent = game.Workspace
Part.CanCollide = true
--Despawn here
Part:Destroy()
end
end)