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

Sword trail not not going inside sword?

So what i mean is im trying to make a sword trail, but when you bring out your sword the "trail" is 4 studs above where it should be or ontop of the sword, if you do not know what i mean play this game: https://www.roblox.com/games/747028397/Sword-Trail-Test

Here is my code:

while wait(0.035) do
	local part = Instance.new("Part", game.Workspace.Trails)
	part.Name = "Trail-ClassicSword"
	part.CanCollide = false
	part.Anchored = true
	part.CFrame = script.Parent.Handle.CFrame - Vector3.new(0,2,0)
	part.Rotation = script.Parent.Handle.Rotation
	part.Size = Vector3.new(0.1,4,0.1)
end

If someone could help me that would be great, have a good day!! :)

1 comment

0

No permissions to join the game..

1 answer

✓ Accepted answer

Your problem is in like 6, here you try to subtract a vector3 from a cframe value, just use cframe

while wait(0.035) do
	local part = Instance.new("Part")
	part.Name = "Trail-ClassicSword"
	part.CanCollide = false
	part.Anchored = true
	part.Size = Vector3.new(0.1,4,0.1)
	part.Parent = game.Workspace.Trails

	--[[ As a good practice you should add the object to the parent after you get all the properties done]]--
	-- heres what you should do instead
	part.CFrame = script.Parent.Handle.CFrame*CFrame.new(0,2,0)
	-- thats how you add to a cframe value
	-- we also dont need the rotation code line because thats part of the cframe
	
	game.Debris:AddItem(part,1)
	-- this is just to remove it or else you are going to have a lot of lag.
end

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