I was trying to make a script, what makes a part called "beam" to appear, if the turrets "range2" part is touched, having one side at the turret, and second side at another part called "regular". I think everything is good to go, but the function wont run when the turrets "Range2" part is touched.
script.Parent.Range2.Touched:connect(function(enemy)
print("touched")
if enemy.Parent.Name == "Enemies" then
print("rekt")
local mag = (script.Parent.BeamS.Position - enemy.Position).magnitude
local beam = Instance.new("Part")
beam.BrickColor = BrickColor.new("Lily white")
beam.Material = "Neon"
beam.Transparency = 0.25
beam.Anchored = true
beam.CanCollide = true
beam.Size = Vector3.new(0.3,0.3,mag)
beam.CFrame = CFrame.new(script.Parent.BeamS.Position, enemy.Position)*CFrame.new(0,0,-mag/2)
beam.Parent = game.Workspace.CurrentCamera
end
end)
(This is the whole script)
And the OutPut doesn't print neither "rekt" or "touched".

2 comments
I tried with both localscript and script, and didn't work, the script is not disabled, and the "Range2" does exist. and i cant use remote events sadly.
Well you can't grab the current camera with a server sided script, you can only do it with a local script. So you need to find a way to make the script and local script communicate to each other, i.e. Remote events.