I'm trying to make a ro-bio CHAOS game where you can inject other players, the needle works on NPC'S but it just goes right through another player, here's the script in the needle item.
tool = script.Parent
function tween(part,poartpp,spded)
local tweenService = game:GetService("TweenService")
local tweeningInformation = TweenInfo.new(
spded, -- Length
Enum.EasingStyle.Elastic, -- Easing style of the TweenInfo
Enum.EasingDirection.Out, -- Easing direction of the TweenInfo
0, -- Number of times the tween will repeat
false, -- Should the tween repeat?
0.1 -- Delay between each tween
)
local Tween = tweenService:Create(part,tweeningInformation,poartpp)
Tween:Play()
end
local RunService = game:GetService('RunService')
local both = script.Parent.Needle
local needle = both.metal
weld = needle.Weld
usable = true
can = true
both.bio.Virus.Changed:connect(function()
if both.bio.Virus.Value ~= nil then
if both.bio.Virus.Value.Name == "Biologic" then
both.bio.BrickColor = BrickColor.Random()
else
both.bio.BrickColor = game.Lighting:FindFirstChild(both.bio.Virus.Value.Name .."C").Value
end
else
both.bio.BrickColor = BrickColor.new("Medium stone grey")
end
end)
tool.Activated:connect(function()
if usable then
if can then
can = false
needle.Sound:Play()
tween(weld,{C1 =weld.C1 * CFrame.new(2,0,0.2)},0.5)
wait(0.7)
tween(weld,{C1 =weld.C1 * CFrame.new(-2,0,-0.2)},0.5)
wait(1)
can = true
end
end
end)
both.Hit.Touched:connect(function(hit)
if usable then
if can == false then if hit.Parent:FindFirstChild("Humanoid") then if hit.Name ~= "HumanoidRootPart" and hit.Anchored == false then
if not game.Players:FindFirstChild(hit.Parent.Name) then
local huma = hit.Parent:FindFirstChild("Humanoid")
if (both.bio.Position - hit.Position).Magnitude < 1 then
usable = false
hit.Parent.Humanoid:TakeDamage(6)
local tos = needle.CFrame:toObjectSpace(hit.CFrame)
local new = both:Clone()
new.metal.Weld:Remove()
new.Parent = hit
local we = Instance.new("Weld",new.metal)
we.Part0 = new.metal
we.Part1 = hit
we.C1 = tos:inverse()
new.metal.CanCollide = true
new.bio.CanCollide = true
needle.Transparency = 1
both.bio.Transparency = 1
local sond = Instance.new("Sound",hit)
sond.SoundId = "rbxassetid://1306077413"
sond:Play()
sond.PlaybackSpeed = 2
sond.Volume = 2
wait()
local sond = Instance.new("Sound",hit)
sond.SoundId = "rbxassetid://1751518775"
sond:Play()
sond.PlaybackSpeed = math.random(6,10)*0.1
sond.Volume = 1
if new.bio.Virus.Value ~= nil then
local virus = new.bio.Virus.Value:Clone()
virus.Parent = hit.Parent
virus.Name = "Biologic"
end
wait(3)
both.bio.Virus.Value = nil
usable = true
needle.Transparency = 0
both.bio.Transparency = 0.5
end
end
end
end
end
end
end)
and it really DOES work on NPCS i have no idea why doesn't it on Players.

1 comment
on line 97 you are checking if what you hit Isn't in game.players, since the npc's name arent in game.players your code is running?. im not sure if it is intentional but try removing the "not"