Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to do speed up this script that spawns a part connecting another part and the player?

Asked by
Nogalo 148
4 years ago

Hi, my script works there is no error in it. My problem is that now having tested it, it doesn't quite work as I imagined and am hoping someone knows how I can do this better?

The script spawns an orb above another player, this orb is then suppose to dmg players in radius and spawn a part(like a laser beam) connecting the orb and the player in radius. I've achieved this however if the player moves the position the script uses become outdated and it spawns where the parts involved used to be half a second ago, hitting air not the player

The script bellow shows what i do once the player is in range of the orb

    local mag = (POC.Position-v.HumanoidRootPart.Position).Magnitude

                                        if mag > 1 and mag <= 20  then
                                            hum:TakeDamage(25)                                                                                  
                                            local RLC = RL:Clone()
                                            local mag2 = (POC.Position-v.HumanoidRootPart.Position).Magnitude                                       
                                            RLC.Size = Vector3.new(0.3, 0.3, mag2)
                                            RLC.CFrame = CFrame.new(POC.CFrame.p, v.HumanoidRootPart.Position) * CFrame.new(0, 0, -mag / 2)
                                            RLC.Anchored = true
                                            RLC.Parent = workspace
                                            Debris:AddItem(RLC,.15)
                                            wait (0.75)

Answer this question