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

Need help with TweenService with Mouse.Hit position?

Asked by 3 years ago

Hello! I am trying to make a spell; to do so I created a part that clones in the position of my character and then moves to the point my mouse indicates. These are the two scripts.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local CastSpell = script.Parent.CastSpell (--Used to check which spell is on, it's a StringValue)

mouse.Button1Down:Connect(function()
    if CastSpell.Value ~= "" then
        if CastSpell.Value == "Fireball" then
            local hit = mouse.Hit.Position
            game.ReplicatedStorage.RemoteEvents.Magics.Fire.FireBall:FireServer(hit)
        end
    end
end)
local TweenService = game:GetService("TweenService")

game.ReplicatedStorage.RemoteEvents.Magics.Fire.FireBall.OnServerEvent:Connect(function(plr, hit)
    local fball = game.ReplicatedStorage.Skills.Fire.Fireball:Clone()

    fball.Position = plr.Character.HumanoidRootPart.Position
    fball.Anchored = true
    fball.Parent = game.Workspace

    local goal = hit

    local tweenInfo = TweenInfo.new(5)

    local tween = TweenService:Create(fball, tweenInfo, goal)

    tween:Play()
end)

The error it gives me is bad argument... please help?

1 answer

Log in to vote
0
Answered by 3 years ago

You have to specify what you want to change in your goal (the position). Also the goal has to be a dictionary and not a variable.

  local goal = {Position = hit}
Ad

Answer this question