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.
Hopefully, its pretty easy!
To do this, you have to create a function, which only activates when the laser is touched, here is an Example :
laser.Touched:Connect(function(shot) -- Make it true!, once the laser is touched, the function will run! if shot.Parent:FindFirstChild("Humanoid") then -- Detects if there is a Humanoid. shot.Parent.Humanoid.Sit = true -- Makes Humanoid sit! else --- Unless.... there is no Humanoid!! return --- Return! end end) -- Sorry, didn't check on studio :(
That is just an example, to make the player trip, and being unable to jump/move, you can change the third line to...
shot.Parent.Humanoid.PlatformStand = true -- Boom!, Player is tripped, and unable to move unless if he presses the BACKSPACE. wait(5) shot.Parent.Humanoid.PlatformStand = false -- Well... just to make it fair!
Hope i helped! Good luck!