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

The part for the laser won't extend for the gaster blaster, It just moves (?)

Asked by 2 years ago

Hello!

I am making a script where when you click with a certain tool equipped It summons a gaster blaster that face depending on where you are and then It shoots a laser, the problem Is the laser, the laser simply refuses for It to extend, however I want the laser to extend on one face which Is where the blaster Is facing

What I mean Is that I want the laser to extend like this:

[0------]

Not like:

[---0---]

But the laser refuses to extend, just simply moving a bit

Script:

local Tool = script.Parent

Tool.RemoteEvent.OnServerEvent:Connect(function()
    local GastGun = game:GetService("ReplicatedStorage").VisualEffectMesh["Gast Gun"]:Clone()
    game:GetService("Debris"):AddItem(GastGun,5)
    GastGun.Parent = game.Workspace
    GastGun.Position = Tool.Parent.Torso.Position
    GastGun.Orientation = Tool.Parent.Torso.Orientation
    GastGun.Transparency = 1
    local TweenProperties = {
        CFrame = GastGun.CFrame + (GastGun.CFrame.LookVector*5),
        Transparency = 0
    }
    local Tweeninfo = TweenInfo.new(
        1,
        Enum.EasingStyle.Bounce,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )
    local Tween = game:GetService("TweenService"):Create(GastGun,Tweeninfo,TweenProperties)
    Tween:Play()
    Tool.Parent.Sounds.OhGodNo:Play()
    wait(0.469)
    local DeltaSize = 9
    local LASER = game:GetService("ReplicatedStorage").VisualEffectMesh["Lazer"]:Clone()
    game:GetService("Debris"):AddItem(LASER,5)
    Tool.Parent.Sounds.Death:Play()
    LASER.Parent = game.Workspace
    LASER.Position = GastGun.Position
    LASER.Orientation = GastGun.Orientation
    local LaserProperties = {
        Size = LASER.Size + Vector3.FromAxis(Enum.Axis.X)*DeltaSize,
        Position = LASER.Position + Vector3.FromNormalId(Enum.NormalId.Front)*DeltaSize/2
    }
    local Tweeninfo = TweenInfo.new(
        1,
        Enum.EasingStyle.Sine,
        Enum.EasingDirection.In,
        0,
        false,
        0
    )
    local Tween = game:GetService("TweenService"):Create(LASER,Tweeninfo,TweenProperties)
    Tween:Play()
    LASER.Touched:Connect(function(hit)
        local humanoid = hit.Parent:WaitForChild("Humanoid")
        if humanoid ~= Tool.Parent.Humanoid then
            humanoid:TakeDamage(math.random(10,50))
            wait(0.1)
        end
    end)
end)
0
To solve this, just simply move the laser in the direction you're trying to extend it. This way, even though it's extending from both sides, since it's also moving forward, it makes up for the extension on the opposite side. joshthegamer456 93 — 2y

1 answer

Log in to vote
1
Answered by
Puppynniko 1059 Moderation Voter
2 years ago
Edited 2 years ago

Some CFrame Magic

 local Goal = {
        Size = Part.Size + Vector3.new(5, 0, 0),
        CFrame = Part.CFrame * CFrame.new(5/2, 0, 0)
}
Ad

Answer this question