I've made a remote that allows an object out of ReplicatedStorage to be cloned and has it's own animation on appearence. It heals the player that ran the event once every second that they are touching and does the same for other players except it damages them. It works great except I want it to attack multiple players touching it and not just one. Any help?
game.Workspace.RosadaRemote:FindFirstChild("Garden").OnServerEvent:Connect(function(Player, Debounce)
local deb = false
local deb2 = false
local AlreadyTouched = false
local Characterl = Player.Character or Player.CharacterAdded:Wait()
Debounce = true
local Garden = game:GetService("ReplicatedStorage"):FindFirstChild("Garden")
local GardenO = Garden:Clone()
GardenO.Name = "Garden"
GardenO.Parent = game.Workspace
GardenO.CFrame = Characterl.HumanoidRootPart.CFrame*CFrame.new(0,-9,0)* CFrame.Angles(0,0,math.pi/-2)
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local Goals = {CFrame = Characterl.HumanoidRootPart.CFrame*CFrame.new(0,-5,0)* CFrame.Angles(0,0,math.pi/-2);}
local Goals2 = {Transparency = 0;CFrame = Characterl.HumanoidRootPart.CFrame*CFrame.new(0,-9,0)* CFrame.Angles(0,0,math.pi/-2);}
local Tween = TweenService:Create(GardenO,Info,Goals)
local Tween2 = TweenService:Create(GardenO,Info,Goals2)
Tween:Play()
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = Characterl.HumanoidRootPart.CFrame.lookVector*0
BV.Parent = GardenO
local PlayersInRadius = {}
GardenO.Touched:Connect(function(Hit)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid == nil then return end
if Humanoid.Parent == Characterl then
if PlayersInRadius[Hit.Parent.Name] == nil then
table.insert(PlayersInRadius, Hit.Parent.Name)
repeat
print("Local Humanoid Touched")
Humanoid.Health = Humanoid.Health+10
wait(1)
until
GardenO.TouchEnded ~= nil
else
if PlayersInRadius[Hit.Parent.Name] == nil then
table.insert(PlayersInRadius, Hit.Parent.Name)
repeat
print("Humanoid Touched")
Humanoid.Health = Humanoid.Health-10
wait(1)
until
GardenO.TouchEnded ~= nil
end
end
end
wait(5)
Tween2:Play()
wait(1.5)
GardenO:Destroy()
wait(0.2)
Debounce = false
end)
end)

1 comment
Pretty much the focus are lines 26-48