Hi,

I've been making a "Wand" as I thought it was a brilliant way in practising remotevents etc. However, I've come across one issue with my wand...

All the spells fire correctly and damage etc.

The only problem is that the aim of the spell is off balanced. When a player shoots a spell, it's not directly inline with the mouse click, instead its off by a little bit making some of the players quite annoyed as they can't use spells on their friends.

Please help..

Server Script - 1 Spell:

--Alohomora--

game.ReplicatedStorage.Powers.OnServerEvent:Connect(function(player, MouseHit, Handle)
B1 = player.Spell.Alohomora.Cooldown.Value
if player.Spell.Value == "Alohomora" then

  if B1 == false then

    local S1 = Instance.new("Part",workspace)

    local S1b = Instance.new("BodyVelocity")

    S1.CFrame = Handle.CFrame
    S1.Anchored = false
    S1.CanCollide = true
    S1.formFactor = "Symmetric"
    S1.Shape = "Ball"
    S1.Size = Vector3.new(1.5,1.5,1.5)
    S1.TopSurface = "Smooth"
    S1.BottomSurface = "Smooth"
    S1.Transparency = 1
    S1.Name = "Alohomora"
    S1.Elasticity = 1
    S1.Friction = 0
    S1.Name = "Alohomora"
    S1.BrickColor = BrickColor.new("Bright blue")
    S1b.Velocity = MouseHit.lookVector*100
    S1b.Parent = S1

	local Eps1 = Effect.Alohomora:Clone()
	Eps1.Parent = S1
	
    player.Spell.Alohomora.Cooldown.Value = true
	player.Spell.Alohomora.Value = false
	
    S1.Touched:Connect(function(Hit)
	local Hum = Hit.Parent:FindFirstChild("Humanoid")
		if Hum ~= nil then
      if Hum.Parent.Name == player.Name then
        wait(0.01)

      else

        wait(0.01)

       game:GetService("Debris"):AddItem(S1,2)

	end
    end
    end)

    if RapidAlohomora[player.UserId] then	
		wait(.25)
player.Spell.Alohomora.Cooldown.Value = false
player.Spell.Value = "Alohomora"
player.Spell.Alohomora.Value = true

      game:GetService("Debris"):AddItem(S1,2)

	else
player.Spell.Value = "Stupefy"
	player.Spell.Stupefy.Value = true
player.Spell.Alohomora.Value = false
game:GetService("Debris"):AddItem(S1,2)

wait(6)

      player.Spell.Alohomora.Cooldown.Value = false
   
  end
end
end

end)

Local Script:

local Tool = script.Parent
local toolTip = script.Parent.Handle
 
Tool.Equipped:connect(function(Mouse)
    Mouse.Button1Down:connect(function()

        game.ReplicatedStorage.Powers:FireServer(Mouse.Hit, Tool.Handle)

    end)
end)

Thank you for the help!

2 comments

1

Use raycasting, lerp the part from the start to the hit position

0

Is there no other way to do it?