Destroying a part in a model from a Local Script Click Detector(PAYING 200 ROBUX)

there are a bunch of problems they are all named cookie now, you can only pick up some of the items and if you equip the tool it duplicates it in workspace.

1 Like
  1. that is for you to change, ive put it in the script, the name of it must match the tool name. you can do that yourself to match your tools
  2. its to prevent picking up the same item twice, since theyre all cookies, u can only pick up 1 cookie
  3. theyre not duplicated, its js new one spawning in. you can change the interval urself
2 Likes

Why not just hire a scripter? This is devforum, for the poor. Go to talent hub if you’re paying. You’re making me sad. :sob:

2 Likes

fr bro :sob:

also a minor code update on the server script one

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Name = "ToolClaimEvent"
remoteEvent.Parent = ReplicatedStorage

local lootsFolder = ServerStorage:WaitForChild("Loots")


local function handleLootItems(lootModel: Model)
	for _,part in lootModel:GetChildren() do
		if not part:IsA("BasePart") then continue end
		
		local detect = Instance.new("ClickDetector")
		detect.Parent = part
		detect.MaxActivationDistance = 32
		
		detect.MouseClick:Connect(function(player: Player)
			local tool = game:GetService("ServerStorage"):WaitForChild("Tools"):FindFirstChild(part.Name) -- Checks if theres a tool with the same name as the clicking part
			if not tool then return end
			local playerBackpack = player:WaitForChild("Backpack")
			if not playerBackpack:FindFirstChild(tool.Name) and not player.Character:FindFirstChild(tool.Name) then
				tool:Clone().Parent = playerBackpack
				remoteEvent:FireClient(player,part)
			end
		end)
	end
end

local function spawnLoots(lootName: string,spawnCFrame)
	local existing = lootsFolder:FindFirstChild(lootName)
	if not existing then return end
	local cloned = existing:Clone()
	
	pcall(function()
		if cloned.PrimaryPart and spawnCFrame then
			cloned.PrimaryPart.CFrame = spawnCFrame
		end
	end)
	
	cloned.Parent = workspace:WaitForChild("Loots")
	handleLootItems(cloned)
end

local allLoots = {"LootTools1","LootTools2","LootTools3","LootTools4"}
spawnLoots(allLoots[math.random(1,#allLoots)]) -- remove?
while task.wait(15) do
	if math.random()>0.75 then
		spawnLoots(allLoots[math.random(1,#allLoots)])
	end
end

mark me as solution im farming solutions rn dwg

1 Like

if it works ill do that and pay u i got to test everything first.

1 Like

almost working just one more problem if you have 2 apples and pick one up u cant pick the other up same for the 2 cookies. i want it to stay under the same name and not make a new apple tool.

1 Like

if u already have 1 tool, you cant pick the other tool.

send me a video of the bug

2 Likes

it says the file is too big… its literally a 7 second clip.

1 Like

now its broken even more, 2 of the models spawn in one game and now it doest delete anything.

1 Like

its only giving the tools now.

1 Like

ToolPickUp Test.rbxl (61.9 KB)

take a look, i hardly changed anything.

ToolPickUp Test.rbxl (61.6 KB)

mb one typo

nvm that one dosnt work u made a remote event so it was awaiting event from the wrong event try this
ToolPickUp Test.rbxl (61.6 KB)


you can only claim one of the 2 tools still tho.

1 Like

ToolPickUp Test.rbxl (61.6 KB)

k just got to check one more thing does the model spawn multiple times or no?

idk how u want it to do it dawg, here it does spawn multiple.

i just want one per game. i was just wondering if it spawned multiple tho. how should i go about changing it so only one spawns per game?

1 Like

it alr does dat, spawns once at the start n thas it

u can check the server script code, spawn it urself at anytime with

spawnLoots(name)
2 Likes

gonna do one last test then im done.

1 Like