Hello there.
I have a laser pointer on my place.
It is just a tool composed of a LocalScript and a Brick with a Mesh.
Here's the LocalScript:
transparency = 0.2
lp = script.Parent
pointing = false
function Click(mouse)
pointing = true
while pointing do
laser = Instance.new("Part")
laser.formFactor = 0
laser.BrickColor = BrickColor.new("Bright red")
laser.Anchored = true
laser.CanCollide = false
laser.Size = Vector3.new(1, 1, 1)
laser.Transparency = transparency
hpos = lp.Handle.Position+((lp.Handle.CFrame*CFrame.fromEulerAnglesXYZ(math.pi/2, 0, 0)).lookVector/-2.5)
dir = CFrame.new(hpos, mouse.Hit.p)
dist = (mouse.Hit.p-hpos).magnitude
mesh = Instance.new("CylinderMesh")
mesh.Scale = Vector3.new(0.3, dist+0.25, 0.3)
mesh.Parent = laser
laser.CFrame = dir*CFrame.fromEulerAnglesXYZ(math.pi/2, 0, 0)+(dir.lookVector*dist/2)
laser.Parent = game.Workspace.CurrentCamera
wait()
laser:Remove()
end
end
function Unclick(mouse)
pointing = false
end
function Equip(mouse)
if mouse == nil then return end
mouse.Button1Down:connect(function() Click(mouse) end)
mouse.Button1Up:connect(function() Unclick(mouse) end)
end
lp.Equipped:connect(Equip)
I would kindly wish to know how to make the laser push people and make them sit when the laser is pointed at them.
I thought of and tried pasting an onTouch function from a Push tool, but it simply does not work. This said tool makes the player fly away a bit when they touch my arm.
Its script is here (yes, it is the onTouched function I tried to upload to the original laser pointer script):
door = script.Parent
function onTouch(hit)
if hit.Parent == nil then return end
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
hit.Parent.Torso.Velocity=door.CFrame.lookVector * 100 -- Push the Player back
end
end
door.Touched:connect(onTouch)
Would you help me out, please?
Thank you.

1 comment
when it touches the player, make the walkspeed 0 and make a trip animation maybe?