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

how im gonna make it so the abilitie doesnt damage myself and still damage other players?

it would be easy if the touched script was a local script but it wont work as local...

game:GetService("UserInputService").InputBegan:connect(function(key)




snake = game.ReplicatedStorage.snake
clone = snake:Clone()
plr = game.Players.LocalPlayer
	



if key.KeyCode == Enum.KeyCode.R then	
if enable == true then return end	
enable = true	
	
ani = Instance.new("Animation")
ani.AnimationId = "rbxassetid://698146588"
load = plr.Character.Humanoid:LoadAnimation(ani)







clone.Parent = game.Workspace	
clone.CFrame = plr.Character.Torso.CFrame * CFrame.new(0,0,-20)	
load:Play()

v = Instance.new("BodyVelocity", clone)	
v.velocity = plr.Character.Torso.CFrame.lookVector * 60	
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)



clone2 = script["Script"]:Clone()	

clone2.Disabled = false
clone2.Parent = clone
	
wait(3)
enable = false		
	
	
	
end	
end)	


--the touch script(normal script): 

test = true


script.Parent.Touched:connect(function(plr)
	
if plr.Parent:FindFirstChild("Humanoid") ~= nil then	

if test == true then	
test = false
plr.Parent.Humanoid.Health = plr.Parent.Humanoid.Health - 20	
wait(2)
test = true
end


end
end)
wait(5)
script.Parent:Remove()







2 comments

2

edit to fix the formatting

0

please use the lua button makes things easier to read

1 answer

If you want it to only damage other players then you need to make a variable that locates the player that holds the script or the player who called the function.

When you have done that you would need to use an "if statement" to check if the part that the object hit is not a part that belongs to the player that holds the script.

When the if statement runs, it will need to check if the name of the parts parent is the name of the script holder, if and when the script identifies that it is not the script holder. It will damage the player.

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