Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Need help with TweenService with Mouse.Hit position?

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

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}

This discussion is preserved as it was. New answers, comments, and votes are closed.