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

Sword trail not not going inside sword?

Asked by 7 years ago
Edited 7 years ago

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!! :)

0
No permissions to join the game.. crywink 419 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

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
Ad

Answer this question