Hi so i made a localscript which fires a remoteEvent when tool is activated and will pass the mouse.hit.position
when the remoteEvent is fired, it’ll create 50 parts that will go to the player’s mousePosition
heres the result:
localscript:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent.Parent
local remoteEvent = game.ReplicatedStorage.powerEvents.initialPower2.power
local debounce = false
tool.Activated:Connect(function()
if debounce == false then
debounce = true
local mousePos = mouse.Hit.Position
mouse.TargetFilter = workspace:WaitForChild(player.Name.."'s K-BOT")
remoteEvent:FireServer(mousePos)
end
end)
remoteEvent.OnClientEvent:Connect(function()
wait(5)
debounce = false
end)
serverscript:
local remoteEvent = initialEvent.power
remoteEvent.OnServerEvent:Connect(function(player, mousePos)
local debris = game:GetService("Debris")
local kbot = workspace:WaitForChild(player.Name.."'s K-BOT")
local val = 1
while wait() do
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(2,2,2)
part.Shape = 'Ball'
part.Material = 'Neon'
part.BrickColor = BrickColor.new('Really red')
part.Anchored = true
part.CanCollide = false
part.CFrame = kbot.RootPart.CFrame
debris:AddItem(part, 5)
local tweenService = game:GetService("TweenService")
local tween = tweenService:Create(part, TweenInfo.new((kbot.RootPart.Position - mousePos).Magnitude/100, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Position = mousePos})
local loadAnimation = kbot.Humanoid.Animator:LoadAnimation(kbot.animations.Power1)
loadAnimation:Play()
tween:Play()
val = val + 1
if val == 50 then
break
end
end
remoteEvent:FireClient(player)
end)
However it’s not really the result i wanted.
I want the created parts to move along the mouse when its moving, how would i do that?
something like this btw.
