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

I can't get the spawn CFrame right on my dart create function. Any thoughts?

Asked by 4 years ago

I have a "Working" Dart script that is supposed to create a special mesh server-side positioned from a part in the local tool. The only thing that I could get to work was to list the Dart's CFrame as a CFrame.new() and that spawns the dart at the default location (0,0,0)

--functions
    local function Shoot(player,mouse,tool)
        print("Shot Initiated") 
        local target = CFrame.new(mouse.Hit.p)
        local spawnposition = CFrame.new(tool.Handle.Postion,target)
          local Dart = Instance.new('Part') do
        -- Set up the dart part
            Dart.Name = 'Dart'
            Dart.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before                                                     changing Size
            Dart.Size = dartsize
            Dart.CanCollide = false
        -- Add the mesh
            local mesh = Instance.new('SpecialMesh', Dart)
            mesh.MeshId = dartmesh
                mesh.Scale = meshscale
        -- Add a force   to counteract gravity
            local bodyForce = Instance.new('BodyForce', Dart)
            bodyForce.Name = 'Antigravity'
            bodyForce.force = Vector3.new(0, Dart:GetMass() * Gravity, 0)
            print("MeshCreated")
        -- Create a clone of dart and set its color
            local dartClone = Dart:Clone()
            --game.Debris:AddItem(dartClone, 30)
            dartClone.BrickColor = BrickColor.new(33, 60, 122)
            -- Position the dart clone and launch!
        dartClone.CFrame = CFrame.new() --NOTE: This must be done before assigning Parent
        dartClone.Velocity = dartClone.CFrame.lookVector * dartspeed --NOTE: This should be done before assigning Parent
        dartClone.Parent = game.Workspace       
        end
    end
Click.OnServerEvent:Connect(Shoot)


Answer this question