what i want to achieve is Mutiply my variable with my other variable but it gives this error ServerScriptService.ThrowServer:13: attempt to perform arithmetic (mul) on nil and number
this is my server sided code
local ts = game:GetService("TweenService")
game.ReplicatedStorage.OnThrow.OnServerEvent:Connect(function(Player,Velocity,Target,Pos)
local Ball = script.Snowball:Clone()
if Player.Team == game.Teams["Red Ranger"] then
Ball.Color = Color3.fromRGB(255, 162, 165)
elseif Player.Team == game.Teams["Blue Blobs"] then
Ball.Color = Color3.fromRGB(163, 162, 255)
end
Ball.Parent = game.Workspace
Ball.Position = Player.Character.Head.Position
Ball.Velocity = Pos * Velocity -- error usually occurs here when i am not pointing at a humanoid
if Target and Target.Parent:FindFirstChild("Humanoid") then
-- if game.Players:GetPlayerFromCharacter(Target).Team == Player.Team then
-- Damage = 0
-- end
local Distance = math.round((Player.Character.Head.Position-Target.Parent.Head.Position).Magnitude)
if Distance < Velocity/7.5 then
local Dmg = Velocity/20+(66.666-(Distance/2))/2
Target.Parent.Humanoid:TakeDamage(Dmg)
end
if Target.Parent.Humanoid.Health == 0 then
print("death")
end
end
end)
This is client sided
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local rs = game:GetService("RunService")
local event = game.ReplicatedStorage.OnThrow
local db = false
local Speed = 100
local Hold = false
local MaxSpeed = 1000
mouse.Button1Down:Connect(function()
if not db then
Hold = true
script.Parent.Visible = true
end
end)
mouse.Button1Up:Connect(function()
Hold = false
script.Parent.Visible = false
if not db and not Hold then
db = true
local Target = mouse.Target
if Target and Target.Parent:FindFirstChild("Humanoid") then
event:FireServer(Speed,Target,mouse.Hit.LookVector)
script.Whoosh.Volume = Speed/200
script.Whoosh:Play()
else
event:FireServer(Speed)
script.Whoosh.Volume = Speed/200
script.Whoosh:Play()
end
wait(0.5)
Speed = 100
db = false
end
end)
rs.RenderStepped:Connect(function()
script.Parent.Front:TweenSize(UDim2.fromScale(1,1-(Speed/MaxSpeed)+0.1),"Out","Sine",0.25)
end)
while true do
if Hold == true and Speed < MaxSpeed then
Speed = Speed + 100
end
wait(0.25)
end
as you can see i mentioned a comment in the server sided script please read it