Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago

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

~~~~~~~~~~~~~~~~~enable = false 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
edit to fix the formatting User#10445 15 — 7y
0
please use the lua button makes things easier to read farrizbb 465 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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.

Ad

Answer this question