I have created a wand that uses Rays,Tweens and FireAllClient to move projectiles and ensures a smooth performance..
I have come to realise, that when you're playing on your own, the damage is equal to the value determined by the spell count.
For each additional player, that damage is doubled per player.
Eg. Original = 20 1 Player = 20 2 Players = 40 3 Players = 60
etc...
I'm really unsure why this is happening...
I have also realised that if I was to place the value of damage to a minus giving the result of (Health) - (-value) It is supposed to heal the player yet does nothing.
Any ideas?
Server:
local ReplicatedStorage = game.ReplicatedStorage
local Event = ReplicatedStorage.Spells
local fire = script.Parent.Handle.Available
local TheEffects = require(script.theEffects)
local Deb = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
ReplicatedStorage.WandClicks.OnServerEvent:Connect(function(player, mouseLocation, tool)
if fire.Value == false then
warn("Don't fire")
elseif tool.Handle.Spell.Value == "None" then
print("No spell Selected")
elseif tool.Handle.Spell.Value == "Protego" then
fire.Value = false
local Pro = game.ReplicatedStorage.SpellsFolder.Effects.Protego:Clone()
Pro.Position = player.Character.HumanoidRootPart.Position
local NGoal = {}
NGoal.Size = Vector3.new(15, 15, 15)
local tweenInfo = TweenInfo.new(1)
local tween2 = TweenService:Create(Pro, tweenInfo, NGoal)
Pro.Parent = workspace
Deb:AddItem(Pro,3)
tween2:Play()
wait(.25)
fire.Value = true
wait(1.75)
local NewGoal = {}
NewGoal.Size = Vector3.new(.2, .2, .2)
local NewInfo = TweenInfo.new(1)
local NewTween = TweenService:Create(Pro, NewInfo, NewGoal)
NewTween:Play()
elseif tool.Handle.Spell.Value == "Lumos" and tool.Handle.PointLight.Enabled == false then
tool.Handle.PointLight.Enabled = true
tool.Handle.Spell.Value = "None"
elseif tool.Handle.Spell.Value == "Nox" and tool.Handle.PointLight.Enabled == true then
tool.Handle.PointLight.Enabled = false
tool.Handle.Spell.Value = "None"
else
fire.Value = false
local SpellType = tool.Handle.Spell.Value
local ending = coroutine.wrap(function()
wait(.25)
fire.Value = true
end)
ending()
local rayOrigin = Vector3.new(tool.Handle.Position.X, tool.Handle.Position.Y-.5, tool.Handle.Position.Z)
local SentFrom = rayOrigin
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = player.Character:GetDescendants()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local rayDirection = (mouseLocation-rayOrigin).Unit
local distance, result, maxdistance = 0, nil, 200
---
local count = 0
repeat
if distance < maxdistance then
result = workspace:Raycast(rayOrigin, rayDirection * 20, raycastParams)
rayOrigin += (rayDirection * 20)
distance += ((rayDirection * 20)).Magnitude
if result then
local IHit = false
local vel = .5*(SentFrom-result.Position).Magnitude/100 --calculate velocity
IHit = true
Event:FireAllClients(SpellType,SentFrom,result.Position, vel, IHit, result.Instance)
wait(vel)--wait the amount of time it'd take before doing damage
if result.Instance.Parent:findFirstChild("Humanoid") and TheEffects[SpellType].PlayerDamage == 0 then
elseif result.Instance.Parent.ClassName == "Accessory" and result.Instance.Parent.Parent:FindFirstChild("Humanoid") ~= nil and TheEffects[SpellType].PlayerDamage == 0 then
elseif result.Instance.Parent.ClassName == "Accessory" and result.Instance.Parent.Parent:FindFirstChild("Humanoid") ~= nil and TheEffects[SpellType].PlayerDamage >= 1 then
local Damage = 0
repeat
wait(TheEffects[SpellType].TimedTween)
Damage = Damage + 1
result.Instance.Parent.Parent:findFirstChild("Humanoid").Health = result.Instance.Parent.Parent:findFirstChild("Humanoid").Health - (TheEffects[SpellType].PlayerDamage)
until Damage == TheEffects[SpellType].RepeaterDamage or result.Instance.Parent.Parent:findFirstChild("Humanoid").Health <= 0
elseif
result.Instance.Parent:findFirstChild("Humanoid") and TheEffects[SpellType].PlayerDamage >= 1 then
local Damage = 0
repeat
wait(TheEffects[SpellType].TimedTween)
Damage = Damage + 1
result.Instance.Parent:findFirstChild("Humanoid").Health = result.Instance.Parent:findFirstChild("Humanoid").Health - (TheEffects[SpellType].PlayerDamage)
until Damage == TheEffects[SpellType].RepeaterDamage or result.Instance.Parent:findFirstChild("Humanoid").Health <= 0
else
end
break
end
else
local IHit = false
local RInstance = nil
Event:FireAllClients(SpellType,SentFrom,rayOrigin, .5*(SentFrom-rayOrigin).Magnitude/100, IHit, RInstance)
break
end
count += 1
wait()
until count >= 20
---
end
end)
Local:
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Spells = game.ReplicatedStorage.Spells
local WandClicks = game.ReplicatedStorage.WandClicks
local Debris = game:GetService("Debris")
local Eqp = false
local Tool = script.Parent
local plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
repeat wait() until plr:HasAppearanceLoaded()
raycastParams.FilterDescendantsInstances = plr.Character:GetDescendants()
local function getPosition(mouseXY)
local x,y = mouseXY.X,mouseXY.Y
local ray = Camera:ViewportPointToRay(x,y)
local result = workspace:Raycast(ray.Origin, ray.Direction*1000,raycastParams)
if result then
return result.Position
else
return ray.Origin+(ray.Direction*500)
end
end
Tool.Equipped:Connect(function(Mouse)
Eqp = true
UIS.InputBegan:Connect(function(input,gp)
if not gp then
if input.UserInputType == Enum.UserInputType.MouseButton1 and Eqp == true then
print("send")
WandClicks:FireServer(getPosition(UIS:GetMouseLocation()), script.Parent)
end
end
end)
end)
Tool.Unequipped:Connect(function()
Eqp = false
end)
Spells.OnClientEvent:Connect(function(spell,SentFrom,SentTo, Velocity, IHit, RInstance)
local spellMake = require(script.Parent.MainConsole.theEffects)
local theSpellEf = spellMake[spell].Effect
local SplashEffect = spellMake[spell].HitEffect
local theSpell = theSpellEf:Clone()
theSpell.SpellTrail.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, spellMake[spell].Colour1),
ColorSequenceKeypoint.new(1, spellMake[spell].Colour2),
}
theSpell.SpellTrail.Inner.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, spellMake[spell].Colour3),
ColorSequenceKeypoint.new(1, spellMake[spell].Colour4),
}
theSpell.CFrame = CFrame.new(SentFrom)
local tweenInfo = TweenInfo.new(Velocity) --get velocity from server
local goal = {
["CFrame"] = CFrame.new(SentTo)
}
local tween = TweenService:Create(theSpell, tweenInfo, goal)
theSpell.Parent = workspace
tween:Play()
local ending = coroutine.wrap(function()
local AT0 = theSpell.AT1--Tool.Handle.AT1
local AT1 = theSpell.AT2
for Move = 1,math.huge do wait()
AT1.Position = Vector3.new(0, 0, 0)
wait()
AT1.Position = Vector3.new(0, .6, 0)
end
end)
ending()
tween.Completed:Connect(function(playbackState)
if playbackState == Enum.PlaybackState.Completed and IHit == true and RInstance.Parent:findFirstChild("Humanoid") == nil and RInstance.Name == "Protego" then
theSpell:Destroy()
elseif playbackState == Enum.PlaybackState.Completed and IHit == true and RInstance.Parent:findFirstChild("Humanoid") == nil then
spellMake[spell].BaseHit(theSpell.Position, theSpell)
elseif playbackState == Enum.PlaybackState.Completed and IHit == true and RInstance.Parent:findFirstChild("Humanoid") ~= nil then
theSpell:Destroy()
spellMake[spell].HitPlayer(RInstance.Parent)
elseif IHit == false and RInstance == nil then
theSpell:Destroy()
end
end)
end)
Any help would be appreciated! Thank you!

2 comments
Does the above code give any errors? If so which errors?
No errors at all