When you welded it to the HumanoidRootPart it rotates with it. I’d suggest just removing the whole object entirely and use beams instead which only needs two attachments. Here is my recreation:
If you want the thing to animate I guess just lerp the attachment to the enemy’s humanoidrootpart?
I’m not entirely sure if it’s gonna work nor do I have any fixes to your current system.
StartAttachment.Parent = player.Character.HumanoidRootPart
for i = 0, 1, 0.05 do
EndAttachment.CFrame = EndAttachment.CFrame:Lerp(EnemyHRP, i)
task.wait(1/60)
end
-- This is all in the client I presume
local TweenService = game:GetService("TweenService")
local currentCamera = workspace.CurrentCamera
-- Attachments
local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
local EndAttachment = Instance.new("Attachment", otherPart)
local Beam = Instance.new("Beam", currentCamera)
Beam.Texture = "rbxassetid://0" -- Texture
Beam.FaceCamera = true
Beam.Attachment0 = StartAttachent
Beam.Attachment1 = EndAttachment
EndAttachment.WorldPosition = StartAttachent.WorldPosition
TweenService:Create(EndAttachment, TweenInfo.new(2), {Position = Vector3.new()}):Play() -- Tween it and stuff
Assuming you don’t want it to connect directly to the enemy player, you could just simply make another part, parent it in currentCamera and change the position the same way the dash did it in post 3:
local Part = Instance.new("Part", currentCamera)
Part.Anchored = true
Part.Transparency = 1
Part.Position = player.Character:WaitForChild("HumanoidRootPart").Position + player.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * dist
local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
local EndAttachment = Instance.new("Attachment", Part)
I was trying to change somthing on the script but i can’t from what i expected
I was trying to make when part goes forward to rotate with HumanoidRootPart like end of the video but only goes forward when I was pressed the button but when i was rotate:
only part rotate not rotating entire beam and part
I was trying to make is when player hold R when player rotates beam and part goes forward from player so player can knows where he can dash hit the target but not when part hit player to attach
this is the script:
local TweenService = game:GetService("TweenService")
local currentCamera = workspace.CurrentCamera
local holding = ReplicatedStorage:WaitForChild("holding")
UserInputService.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.R and not gpe then
local clone = holding:Clone()
local Part = Instance.new("Part", currentCamera)
Part.Anchored = false
Part.Transparency = 0
Part.Position = player.Character:WaitForChild("HumanoidRootPart").Position + player.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 2
local weld = Instance.new("Weld",Part)
weld.Part0 = player.Character.HumanoidRootPart
weld.Part1 = Part
local StartAttachent = Instance.new("Attachment", player.Character:WaitForChild("HumanoidRootPart", 2))
local EndAttachment = Instance.new("Attachment", Part)
local Beam = Instance.new("Beam", currentCamera)
Beam.Texture = "rbxassetid://0" -- Texture
Beam.FaceCamera = true
Beam.Attachment0 = StartAttachent
Beam.Attachment1 = EndAttachment
TweenService:Create(Part, TweenInfo.new(2), {Position =
Vector3.new(Part.Position.X,Part.Position.Y,-20)}):Play()
end
end)
Sorry for bad english
Why does need to move forward to show player where he can hit the target,you can make it just disappear
Because i wanted to make when you hold R how much you hold more far you can dash
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local currentCamera = workspace.CurrentCamera
-- If there is a maximum dash distance then plug it into Part.Position
local configuration = {
MaxDashDistance = 50
}
UserInputService.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.R and not gpe then
local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart", 2)
local Part = Instance.new("Part", currentCamera)
Part.CanCollide = false
Part.Massless = true
Part.Transparency = 0.75
Part.Position = HumanoidRootPart.Position + HumanoidRootPart.CFrame.LookVector * configuration.MaxDashDistance
local weld = Instance.new("WeldConstraint", Part) -- Change this to WeldContraint so the parts doesn't have to be touching for it to weld
weld.Part0 = player.Character.HumanoidRootPart
weld.Part1 = Part
local StartAttachent = Instance.new("Attachment", HumanoidRootPart)
local EndAttachment = Instance.new("Attachment", Part)
EndAttachment.WorldPosition = StartAttachent.WorldPosition
local Beam = Instance.new("Beam", currentCamera)
Beam.Texture = "rbxassetid://0" -- Texture
Beam.FaceCamera = true
Beam.Attachment0 = StartAttachent
Beam.Attachment1 = EndAttachment
-- I would just try to tween the end attachment to the part (which is basically the maximum dash distance)
-- then would cancel the tween using tween:Cancel() when the person stops holding R
spawn(function()
local tween = TweenService:Create(EndAttachment, TweenInfo.new(2), {
Position = Vector3.new()
}) tween:Play()
-- Scuffed but it's what I can think of right now
local inputEnded;
inputEnded = UserInputService.InputEnded:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.R and not gpe then
-- Cancel the tween and set part position to EndAttachment.WorldPosition
tween:Cancel()
Part.Position = EndAttachment.WorldPosition
--[[ EXECUTE DASH FUNCTION THING HERE ]]
--local distance = (Part.Position - HumanoidRootPart.Position).Magnitude
--Dash(distance)
--[[ Cleanup ]]
-- i don't know how you destroy the parts, attachments, and welds after so:
Part:Destroy()
weld:Destroy()
StartAttachent:Destroy()
EndAttachment:Destroy()
Beam:Destroy()
-- Disconnect connection
inputEnded:Disconnect()
inputEnded = nil
end
end)
end)
end
end)
If I understand you correctly, you want a visualization of how far a player dashes.
What this basically does is put the part at the maximum dash distance, then tweens the
endAttachment to the Part.
When the player stops holding R, it cancels the tween, and sets the part’s position to the endAttachment’s position.
Finally, we run the dash function, and we cleanup the instances.