Hello, I've got this script, and it's broken, but very weird
What the script is supposed to do is activate when you touch a part called "radar", but instead, it activates when you touch a part called "dot" (Which is placed inside of "radar") And, the damage for touching the part somehow doesn't work, which is weird
Can someone please explain what is wrong with it?
SCRIPT:
local gun = workspace.Turret.Gun
local originpoint = gun.CFrame.p
script.Parent.Radar.radar.Touched:connect(function(plr)
if plr.Parent:IsA("Model") and plr.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.Character:FindFirstChild("Head") then
script.Parent.Gun.alert:Play()
local ignore = {script.Parent,game.Players[plr.Parent.Name]}
local ray = Ray.new(originpoint,plr.Parent.Head.CFrame.p.Unit*100)
local gun,position = workspace:FindPartOnRayWithIgnoreList(ray,ignore,false,true)
local beam = Instance.new ("Part")
beam.BrickColor = BrickColor.Red()
beam.Material = "Neon"
beam.Transparency = .35
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
beam.Parent = gun
beam.Name = "Beam"
local distance = (script.Parent.Gun.CFrame.p-position).magnitude
local Distance = distance/8
repeat
beam.Size = Vector3.new(.15,.15,distance)
beam.CFrame = CFrame.new(script.Parent.Gun.CFrame.p,position)*CFrame.new(0,0,-distance/2)
distance = distance*2
wait (0.01)
until distance == Distance*2
beam.Touched:connect(function(hit)
if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then
local human = hit.Parent:FindFirstChild("Humanoid")
human:TakeDamage(10^308)
game:GetService("Debris"):AddItem(beam,.1)
end
end)
end
end)
Thanks for your time!
~TheRoofyPidgeot

6 comments
LocalPlayer is nil on the server.
what line?
Line 6
Wait does it work on the server?!
localplayer only works on a "local script"
instead do plr.Parent:FindFirstChild("Head")