I’m addind a special ability in my game where it can create a ball that one shots whoever it touches, and it tweens to the mouse, but whenever I test it, Instead of tweening to the mouse, it tweens to 0,0,0
LocalScript
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
local mouse = m.Hit
uis.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.Q then
script.Parent.AbilityEvent:FireServer(mouse)
end
end)
ServerScript
local cooldown = 15
local useTime = 5
local active = false
local oncd = false
local equipped = false
script.Parent.AbilityEvent.OnServerEvent:Connect(function(plr, mouse)
if equipped == true then
if active == false and oncd == false then
active = true
local char = plr.Character
local hrp = char:WaitForChild("HumanoidRootPart")
local cf = hrp.CFrame
local lv = cf.LookVector
local part = Instance.new("Part")
part.CFrame = cf + (lv * Vector3.new(5,5,5))
part.Anchored = true
part.BrickColor = BrickColor.new("Hot pink")
part.Material = "Neon"
part.Shape = "Ball"
part.Size = Vector3.new(4,4,4)
part.CanCollide = false
part.Parent = workspace
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(useTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local goal = {Position = Vector3.new(mouse)}
local tween = ts:Create(part,tweenInfo,goal)
tween:Play()
wait(useTime)
part:Destroy()
active = false
oncd = true
wait(cooldown)
oncd = false
end
end
end)
script.Parent.Equipped:Connect(function()
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
m.Hit is already a Vector3, so putting it inside of Vector3.new() turns it into 0, 0, 0. Try removing the Vector3.new() part from your goal variable to fix the issue:
01:46:01.186 TweenService:Create property named 'Position' cannot be tweened due to type mismatch (property is a 'Vector3', but given type is 'CoordinateFrame') - Server - AbilityServer:32
Hi! Maybe that’s because you pointed the mouse into the sky. Try printing the m.hit.position just to make sure.
If that’s the case, what you can to is set a distance limit for the ability like this (or something like that)
If (player.Character.HumanoidRootPart.Position + m.hit.position).Magnitude > MaxDistance then
Target = player.Character.HumanoidRootPart.CFrame:PointToObjectSpaceP(m.hit.Position) * MaxDistance
End
Not sure if this is right (i’m not a pro scripter) but basically you’ll need to get the normalized direction from the player and the m.hit and multiply it for the distance you want