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

Why doesn't this script get the mouse position properly? [closed]

Asked by 6 years ago
Edited 6 years ago

This question already has an answer here:

Why doesn't this script get the mouse position properly?

When It fires the part goes way above the mouse position. However it works perfectly ih Studio Testing. The Remote Event fires when a key down (Create) and key up (Fire).

My discord: Prismous#1646

local DiscCharging
local events1= Instance.new("RemoteEvent")
events1.Name = "DestructoDiscEvent"
events1.Parent = game.ReplicatedStorage.RemoteEvents.Skills
events1.OnServerEvent:connect(function(plr,Statis,Mouse)
    Player = plr
    local FormMultiplier = plr.Gamestuff.Characters.Folder.FormMultiplier.Value
    local Damage = SaiyanModule.damage(plr, 15,FormMultiplier)
    print(Damage)
    if Statis == "Create" then
      local Disc= Instance.new("Part",plr.Character)
      Disc.Name = "Disc"
      Disc.BrickColor = BrickColor.new("Cool yellow")
      Disc.Material = "Neon"
      Disc.TopSurface = "Smooth"
      Disc.BottomSurface = "Smooth"
      Disc.FormFactor = "Custom"
      Disc.Size = Vector3.new(0.2, 3.12, 7.44)
      Disc.Transparency = 0.2
      Disc.Anchored = false
      Disc.CanCollide = false
      Disc.CFrame = plr.Character.LeftUpperArm.CFrame * CFrame.new(0, 0, 0)--* CFrame.new(0,-4, 0)* CFrame.Angles(0, 0, -math.rad(90)) --* CFrame.new(0, 0, 0)
      local CylinderMesh = Instance.new("SpecialMesh")
      CylinderMesh.Name = "CylinderMesh"
      CylinderMesh.MeshType = "Cylinder"
      CylinderMesh.Parent = Disc
      CylinderMesh.Scale = Vector3.new(0.2, 1.1, 1.1)
      local Weld = Instance.new("Weld")
      Weld.Parent = Disc    
      Weld.Part0 =    Disc
      Weld.Part1 =  plr.Character.LeftHand
      Weld.C0 = CFrame.new(1, 0, 0) * CFrame.Angles(0, 0, -math.rad(90))
      DiscCharging = true
       Rotate = true
        plr.Character.HumanoidRootPart.Anchored = true
       plr.Character.RotatePlayer.Disabled = false
      biggerdisc(plr,CylinderMesh,Mouse)
    elseif Statis == "Fire" then
        local Weld = Player.Character. Disc.Weld
        local CylinderMesh = Player.Character. Disc.CylinderMesh
        local Disc = Player.Character. Disc
        Weld:Destroy()
       plr.Character.RotatePlayer.Disabled = true
        plr.Character.HumanoidRootPart.Anchored = false
        DiscCharging = false
    wait(0.001)
      local bv = Instance.new("BodyVelocity")
      bv.velocity = CFrame.new(Disc.Position, Mouse.p).lookVector*80
      bv.maxForce = Vector3.new(math.huge, math.huge, math.huge)
      bv.Parent = CylinderMesh.Parent
      game:GetService("Debris"):AddItem(CylinderMesh.Parent, 4)
      local debounce = false
      CylinderMesh.Parent.Touched:connect(function(hit)
        if debounce == true then return end
        debounce = true
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("NPC") == nil and hit.Parent.Name ~= plr.Name  then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health  - Damage
            DamageTakerGUI(plr,hit,Damage)
        end
        wait(1)
        debounce = false
    end)
    end
end)

function biggerdisc(Player,Cylinder,Mouse)
    while DiscCharging and Cylinder.Scale.Y <= 2 and wait() do
         for i = 1,5 do
            Cylinder.Scale = Cylinder.Scale + Vector3.new(0,.005,0)
            wait()
         end
        wait()
    end
end

Marked as Duplicate by cabbler and shayner32

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?