I am making a potion game were you brew potions and you fight each other. But I am struggling to make a throwing potion that inserts a script into their character models if they get close enough. But I can't get to work, or make it so only one script is inserted, and can detect that an infected script is already present in an infected player:
Here is my script:
function PWNEM()
while true do
wait()
local ply = game.Workspace:GetChildren()
for i = 1, #ply do
local infection = script.Affect
if ply[i]:findFirstChild("Humanoid") ~= nil then
if (script.Parent.Nade.Position - ply[i].Torso.Position).magnitude <= 15 then
infection:Clone()
infection.Parent = ply[i].Torso
end
end
end
end
end
wait(3)
s = Instance.new("Part")
s.Parent = script.Parent
s.Name = "Smoke"
s.Transparency = 1
s.Size = Vector3.new(1,1,1)
s.Shape = "Block"
s.TopSurface = "Smooth"
s.BottomSurface = "Smooth"
s.BrickColor = BrickColor.new("Alder")
s.Anchored = true
s.CanCollide = false
s.Position = script.Parent.Nade.Position
script.Mesh:clone().Parent = s
script.Smoke:clone().Parent = s
script.Parent.Nade.Anchored = true
wait()
s.Transparency = 1
script.Boom:play()
wait(0.05)
s.Transparency = 1
wait(0.05)
s.Transparency = 1
wait(0.05)
s.Transparency = 1
wait(0.05)
s.Transparency = 1
wait(0.05)
PWNEM()
