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

Sword Not Dealing Damage If Cloned?

I'm not sure why my sword won't deal damage when it is cloned from lighting and given to the player if they click a certain button.

Been trying to figure this out for the last 10 minutes, I have no idea why this is happening? The sword works fine if it's placed in the player's backpack, or picked up

Sword Damage Script

Av = math.random(45.75) --Attack Value

tool = script.Parent

function tagHumanoid(humanoid,killer)

    if humanoid and killer then

        local tag = Instance.new("ObjectValue")
        tag.Name = "creator"
        tag.Value = killer
        tag.Parent = humanoid
    end

end

script.Parent.Activated:Connect(function()
	script.Parent.Handle.blade.Touched:connect(function(p)

	local plr = game.Players:GetPlayerFromCharacter(tool.Parent)

if script.Parent.CanDamage.Value == true and p.Parent:FindFirstChild("Humanoid") then -- checking if its a player

    script.Parent.CanDamage.Value = false

    local humanoid = p.Parent:FindFirstChild("Humanoid")

    humanoid:TakeDamage(47.75)

    tagHumanoid(humanoid, plr)

    wait(1)

    script.Parent.CanDamage.Value = true

    if p.Parent.Humanoid.Health < 1 then
        print("Player Has Died")
    end

    end

end)
end)

Gui/Button Script

script.Parent.MouseButton1Click:Connect(function()
	local plr = game.Players.LocalPlayer
	local backpack = plr:FindFirstChild("Backpack")
	local FindSword = backpack:FindFirstChild("Sword")
	
	if FindSword == false then
		print("Error Player Has Sword")
	else
		local sword = game.Lighting.Sword:Clone()
		sword.Parent = backpack
		print("Player Has Recieved A Sword")
		script.Parent.BackgroundTransparency = 0.85
	end
end)

3 comments

0

wdym? do you mean if its cloned into the player directly or something like workspace?

0

The sword is cloned to the player if a "Give Sword" button is pressed

0

The animations, sound and everything else works except for the sword dealing damage?

1 answer

Ah, I figured it out

I put the script inside a local script..

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