so im trying to make a script where if you are next to this specific part, lets name it "Sword" then the sword will go to the players position and if it does not touch the player then it will destroy it self, and if it does then the player dies. Here is what i done, i just dont know how to do the move to player when the player is next to the sword part of the script. I think i will need to use magnitude though.
Script:
local Sword = script.Parent
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Start = Sword.Position
local PartToMove = Sword
local End -- humanoid root part here, but idk if a normal script can have access to the character
local TweenInformation = TweenInfo.new(
0.62,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local EndProperties = {
Position = End.Position
}
local TweenToPlay = TweenService:Create(PartToMove, TweenInformation, EndProperties)
local Sword = script.Parent
while true do
Sword.CFrame = Sword.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.45, 0)
wait()
end
Sword.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Health = 0
end
end)
-- if the player is 32 studs next the sword, the sword will play the tween.

1 comment
Thanks! I will try it and change it a bit and play around, thanks for answering! :D