I may be wrong, but is the blade even moving? It looks like you only set the blade to have a CFrame.Angle of math.rad(.1). Shouldn’t you be adding the angle per each loop instead?
Sorry, after researching further, you are doing it correctly. Btw, you do not need to say CFrame.new(blade.CFrame.Position). Simply say blade.CFrame. I think that may be messing things up because you are resetting the rotation of the blade when you refer to only the position component of the blade.
The way the player holds the saber is from the back of the handle regardless of orientation iirc, so therefore rotating the handle is also going to mess with the orientation of the player. A potential workaround is to create an invisible handle, link it to the other parts of the saber using a Motor6D (as a weld would cause the exact same problem you’re currently having) and then rotate the Motor6D.
Just a question: Do I have to parent the Moter6D to the Handle?
This is my script so far:
local spin = game.ReplicatedStorage.Remotes.SpinLightsaber
local players_spinning = {}
game.Players.PlayerAdded:Connect(function(plr)
players_spinning[plr.Name] = false
end)
spin.OnServerEvent:Connect(function(plr, spinning)
local saber = plr.Character:WaitForChild("Lightsaber")
local invisHand = saber.Handle
players_spinning[plr.Name] = not players_spinning[plr.Name]
while players_spinning[plr.Name] do
for i, motor in ipairs(invisHand:GetChildren()) do
if motor:IsA("Motor6D") then
motor.CurrentAngle = motor.CurrentAngle + 1
end
end
wait(.5)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
players_spinning[plr.Name] = nil
end)
local spin = game.ReplicatedStorage.Remotes.SpinLightsaber
local RunService = game:GetService("RunService")
local players_spinning = {}
game.Players.PlayerAdded:Connect(function(plr)
players_spinning[plr.Name] = false
end)
local ROTATE_ANGLE = 15 -- how much you want to rotate per second in degrees
spin.OnServerEvent:Connect(function(plr, spinning)
local saber = plr.Character:WaitForChild("Lightsaber")
local invisHand = player.Character:WaitForChild("RightHand")
players_spinning[plr.Name] = not players_spinning[plr.Name]
while players_spinning[plr.Name] do
local delta = RunService.Stepped:Wait()
for i, motor in ipairs(invisHand:GetChildren()) do
if motor:IsA("Weld") then -- because the handle attach is a weld
motor.C0 = motor.C0 * CFrame.Angles(math.rad(delta * ROTATE_ANGLE), 0, 0)
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
players_spinning[plr.Name] = nil
end)
Also, you should set the part’s cancollide to false.
local spin = game.ReplicatedStorage.Remotes.SpinLightsaber
local RunService = game:GetService("RunService")
local players_spinning = {}
game.Players.PlayerAdded:Connect(function(plr)
players_spinning[plr.Name] = false
end)
local ROTATE_ANGLE = 15 -- how much you want to rotate per second in degrees
spin.OnServerEvent:Connect(function(plr, spinning)
local saber = plr.Character:WaitForChild("Lightsaber")
local invisHand = player.Character:WaitForChild("RightHand")
players_spinning[plr.Name] = not players_spinning[plr.Name]
while players_spinning[plr.Name] do
local delta = RunService.Stepped:Wait()
for i, motor in ipairs(invisHand:GetChildren()) do
if motor:IsA("Motor6D") then -- because the handle attach is a weld
motor.C0 = motor.C0 * CFrame.Angles(0, 0, math.rad(delta * ROTATE_ANGLE))
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
players_spinning[plr.Name] = nil
end)