I have a mining script that makes a part spawn when it touched a part thats named "Rock". When you touch the rock, the script from the tool clones a script from server storage and it prints "Mineral Collected" when its touched, and destroys the part. But it does not print "Mineral Collected" and it does not destroy the part. Heres the script in the tool (the script that creates the part)
local tool = script.Parent local canMine = true local ServerStorage = game:GetService("ServerStorage") tool.Handle.Touched:Connect(function(hit) if canMine == true then if hit.Name == "Rock" then print("Rock Hit") canMine = false local mineralMined = Instance.new("Part") mineralMined.Parent = game.Workspace mineralMined.Size = Vector3.new(2,1,2) mineralMined.Position = hit.Position + Vector3.new(math.random(-5,5), 5, math.random(-5,5)) local mineralType = math.random(1,100) if mineralType > 50 then mineralMined.BrickColor = BrickColor.new("Medium stone grey") end if mineralType > 75 then mineralMined.BrickColor = BrickColor.new("Institutional white") end if mineralType > 100 then mineralMined.BrickColor = BrickColor.new("Teal") local collectMineral = game.ServerStorage.GetMineral:Clone() collectMineral.Parent = mineralMined end end end end) tool.Activated:Connect(function() local toolanim = Instance.new("StringValue") toolanim.Name = "toolanim" toolanim.Value = "Slash" toolanim.Parent = tool canMine = true end)
heres the script in server storage. ( the script that prints "mineral collected)
local part = script.Parent local function GetMineral(hit) local partParent = hit.Parent local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") if humanoid then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then if part.BrickColor == BrickColor.new("Medium stone grey") then print("Rock Collected") part:Destroy() end if part.BrickColor == BrickColor.new("Institutional white") then print("Iron Collected") part:Destroy() end if part.BrickColor == BrickColor.new("Teal") then print("Diamond Collected") part:Destroy() end end end end part.Touched:Connect(GetMineral)