Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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 comment

1

Thanks, it worked!

This discussion is preserved as it was. New answers, comments, and votes are closed.