Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tool clones part but the cloned part's script won't work?

I've made a script that clones a mesh in front of the player so that when the player clicks the tool it spawns the part as it's supposed to. The problem is that the part being cloned has a script inside of it but it does not trigger or cause an error in the output for whatever reason. Here's the script inside of the tool that clones the mesh: (It's a local script fyi)

local tool = script.Parent


debounce = true

tool.Activated:Connect(function()
	
	if debounce == true then
		debounce = true
		local player = game.Players.LocalPlayer
		local character = player.Character or player.CharacterAdded:Wait()
		local animation = script.Parent.DashMover
		local Anim1 
		local Slash = game.ReplicatedStorage.SlashD:Clone()
		
		Slash.Parent = character.Torso
		local offset = Vector3.new(0,0,-5) 
		Slash.CFrame = character.Torso.CFrame*CFrame.new(offset) 
		
		wait(0.1)
		
		for i = 1,10 do
			Slash.Transparency = Slash.Transparency + 0.1
			wait(0.05)
		end
		Slash:Destroy()
		debounce = true
	end
end)

And this is the script inside of the cloned mesh: (This is inside of a serverscript)

local Debounce = false

script.Parent.Touched:connect(function(hit)
	
	if hit.Parent:FindFirstChild("Humanoid")and Debounce == false then
		Debounce = true
		hit.Parent.Humanoid:TakeDamage(10)
		wait(0.1)
		Debounce = false
		
	end
end)

Any help is appreciated!

1 answer

Try "Instance.New" instead of cloning it.

8 comments

0

How would I get the damage script into the part? I've never done something like that before.

0

if the part hits a part of the player then it takes damage from the humanoid like Humanoid:TakeDamage(25)

0

orr you can subtract the health

0

I mean like how would I get the actual script inside the part. I've already got the script to take damage from the player

0

you can't

0

then instance.new wouldn't work :I

0

I misunderstood you.

0

gotcha

This discussion is preserved as it was. New answers, comments, and votes are closed.