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

How would i remove the fact that the abilities can hurt my self too?

`wait(1)
player = game.Players.LocalPlayer
torso = player.Character:WaitForChild("Torso")
mouse = player:GetMouse()
enabled = true
mouse.KeyDown:connect(function(key)
	if key == "f" and enabled == true then
	game:GetService("Chat"):Chat(player.Character.Head, "MADARA POWER")
	enabled =false
	meteor = Instance.new("Part", game.Workspace)
	meteor.BrickColor = BrickColor.new("Burnt Sienna")
	meteor.Shape = "Ball"
	meteor.Size = Vector3.new(20,20,20)
	meteor.TopSurface = "Smooth"
	meteor.BottomSurface = "Smooth"
	dmg = script.OnDamage:Clone()
	dmg.Parent = meteor
	meteor.CFrame = player.Character.Torso.CFrame*CFrame.new(0,20,-18)
	meteor.Velocity = Vector3.new(0,-50,0)
	meteor.CanCollide = false
    Mesh = game.Lighting["Meteor Mesh"]:Clone()
 	Mesh.Parent = meteor
	wait(.5)
	meteor:Destroy()
	wait(2)
	enabled = true
	end
end)

---------------------------------------------------------------- Diff Script inside this Local Script

function Damage(Part)
	if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= "script.Parent.Name" then
		script.Disabled = true
		Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - 25
	end
	wait()
end

script.Parent.Touched:connect(Damage)

1 answer

✓ Accepted answer

Alright so first let's talk about your code.

Your Code

function Damage(Part)
    if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= "script.Parent.Name" then
        script.Disabled = true
        Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - 25
    end
    wait()
end

script.Parent.Touched:connect(Damage)

First off what you're doing wrong is saying if the person's name is not equal to 'script.Parent.Name'. What you mean to do is ~= script.Parent.Name but even that won't work because your meteor isn't named after your player / the one casting it so therefore it won't be able to know if you're really the creator or not.

Try this:

function Damage(Part)
    if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= script.Parent.Name then
        script.Disabled = true
        Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health - 25
    end
    wait()
end
script.Parent.Touched:connect(Damage)

Also you should probably name your "meteor" after the player that's casting it by simply doing meteor.Name = player.Namein your first script. Also if you want you meteor to hit more than one person, don't make the script disable itself.

I hoped this help. If not please leave a comment or message me, if not, please accept my answer!

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