ok fellas, I've met a roadblock. I have this script, and im out of ideas on how to make it so that this darned new instance can cause damage when to players touching it... whether you can help or not, I thank you for reading this...
local tool = script.Parent local mouse tool.Equipped:Connect(function(m) mouse = m end) tool.Activated:Connect(function() if mouse then local Part = Instance.new("Part",workspace) Part.Position = script.parent.Handle.Position Part.Material = Enum.Material.Neon Part.Size = Vector3.new(0.5,0.5,0.5) Part.CanCollide = false Part.Anchored = true --damage thing goes here end end)
sorry for posting a question that's very similar to my previous one but I really cant think of anything since I'm new and I suck at coding.
All you would need to do is use the variable you set for the part and connect the touched event to deal damage. That would make your script look like this:
local tool = script.Parent local mouse local debounce = false local dmg = --set damage here tool.Equipped:Connect(function(m) mouse = m end) tool.Activated:Connect(function() if mouse then local Part = Instance.new("Part",workspace) Part.Position = script.parent.Handle.Position Part.Material = Enum.Material.Neon Part.Size = Vector3.new(0.5,0.5,0.5) Part.CanCollide = false Part.Anchored = true Part.Touched:Connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h then debounce = true h:TakeDamage(dmg) wait(1) end debounce = false end) end end)
I did a little more than adding touched. One thing I did was add debounce so that the part could only deal damage once every second. The second thing I did was add a variable named "dmg" so you could easily change how much damage the part deals. Hope this helped!