I am making a game and i want it so when you step on a brick it puts a sword on your back. The script i have now is buggy and rotation is off every time, so can anyone help fix it. The sword is a union. I want the sword slanted when it is on your back.
Script:
local De = false
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if De == false then
hit.Parent.HumanoidRootPart.Anchored = true
repeat wait() until hit.Parent.HumanoidRootPart.Anchored == true
local R = hit.Parent.UpperTorso.Orientation.X
De = true
local Sword = game.Workspace.Swords.Starter:Clone()
Sword.Parent = game.Workspace
Sword.CFrame = hit.Parent.UpperTorso.CFrame - hit.Parent.UpperTorso.CFrame.lookVector
Sword.Orientation = Vector3.new(45,R,0)
print(Sword.Orientation)
Sword.Orientation = Vector3.new(45,R,0)
local v = Sword
local Player = hit.Parent
print(Player.Name)
local weld = Instance.new("Weld")
weld.Part0 = Player.UpperTorso
weld.C0 = Player.UpperTorso.CFrame:inverse()
weld.Part1 = v
weld.C1 = v.CFrame:inverse()
weld.Parent = v
v.Anchored = false
print(Sword.Orientation)
hit.Parent.HumanoidRootPart.Anchored = false
wait(1)
print(Sword.Orientation)
wait(4)
De = false
end
end
end)
Thanks for helping!
