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

Decal block won't spawn in the right position, why is that?

Asked by
Ghost40Z 118
3 years ago

I am making a lightning attack for my game using my own modulescript. However when I tried adding a magic casting circle, the block that the decal was on would rotate correctly but not appear where specified (5 studs infront of the HumanoidRootPart). It spawns 5 studs in the -Z axis in the world ignoring the humanoid root part.

Here is the part of the script:

if distance >= 5 and distance <= math.huge then
        humanoid.WalkSpeed = 0
        humanoid.JumpPower = 0
        local playAnim = humanoid:LoadAnimation(anim)
        playAnim:Play()
        HRP.CFrame = CFrame.new(HRP.Position, HRP.Position + hit.lookVector)

        decal.Position = HRP.Position
        decal.CFrame = CFrame.Position + Vector3.new(0,0,-5)


        Folder.Parent = workspace

        wait(.2)        
        local lightning = LightningModule.createLightning(decal.Position, endpart.Position, 20)
        sound:Play()
        wait(.2)
        playAnim:Stop()
        lightning:Destroy()
        Folder:Destroy()
        humanoid.WalkSpeed = 16
        humanoid.JumpPower = 50 
    end

1 answer

Log in to vote
1
Answered by
Rinpix 639 Moderation Voter
3 years ago

You're setting the CFrame of the part to a Vector3 value:

decal.Position = HRP.Position
decal.CFrame = CFrame.Position + Vector3.new(0,0,-5)

You should just be doing this:

decal.CFrame = HRP.CFrame * CFrame.new(0, 0, -5)
1
Thanks, it worked! Ghost40Z 118 — 3y
Ad

Answer this question