crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 30 Jul 2016 01:26 PM |
Hello,
I have to create a ManualWeld to make the player's head rotate when he moves his mouse.
When he unequips the tool, I destroy the weld so it can move back normally.
However, it only works in Edit mode. In online mode, the player dies when he uneqips his tool.
Actually, I have many welds related, but I presume the one linking the head to torso causes the problem.
These welds are located inside a folder. The folder is destroyed when the player unequips his tools:
weldFolder:destroy()
Anyone know what to do to fix the online/Edit difference?
Tkx,
Crate |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Jul 2016 01:27 PM |
There always needs to be a weld between the head and the torso, if there does not exist one, the character dies immediately.
|
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 30 Jul 2016 01:29 PM |
But I create the manual weld when the player equips the tool. Is there not a weld by default?
I only delete the weld I created myself, not the one by default. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Jul 2016 01:34 PM |
I wonder if they overwrite.
I would instead weld the tool to your Right Arm
|
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
| |
|
|
| 05 Aug 2016 08:24 PM |
| I think you may have to reset the neck motor6ds properties. Your weld probably breaks it. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:24 PM |
| I tried making the Welds nil instead of removing them, still, not working |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:25 PM |
@Too, Sorry for last post, didn't refresh the page to see your comment ;)
I'll try that,
tkx. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:29 PM |
| Is there a function to reset it? Not finding much on google |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2016 08:35 PM |
I am trying to kill the player like what you're describing but it's not working.
Script:
local plr = game.Players.LocalPlayer wait(1)
local char = plr.Character
local weld = Instance.new("Weld", char) weld.Part0 = char.Head weld.Part1 = char.Torso weld.C0 = CFrame.new(0, -1.5, 0) * CFrame.Angles(0, 5, 0)
wait(0.5)
weld:Destroy()
I know it's awful and messy and what not but I was just in a rush to try to achieve what you're describing. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:38 PM |
Your code seem similar to mine:
function SetWelds() Head = Player:FindFirstChild("Head") Body = Player:FindFirstChild("Torso") weldFolder = Instance.new("Folder") weldFolder.Name = "weldFolder" weldFolder.Parent = Player headAttachToBody = Instance.new("ManualWeld")
headAttachToBody.Parent = weldFolder
headAttachToBody.Part0 = Body
headAttachToBody.Part1 = Head
end
-- I removed many welds, but they are all related to arms or legs, so not much important. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:39 PM |
| My script, however, is a Localscript located inside the tool. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:43 PM |
This is the head rotation part:
game:GetService("RunService").RenderStepped:connect(function() if not(Player == nil) then headAttachToBody.C0 = CFrame.new(0,1.5,0) * CFrame.fromEulerAnglesXYZ(math.asin((PlayerMouse.Hit.p - PlayerMouse.Origin.p).unit.y),0,0) end end)
And the weld deleting part:
function RemoveWelds() weldFolder:destroy() end |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2016 08:44 PM |
local plr = game.Players.LocalPlayer wait(1)
local char = plr.Character
char.Torso.Neck.Part0 = nil char.Torso.Neck.Part1 = nil
local weld = Instance.new("Weld", game.Workspace) weld.Part0 = char.Head weld.Part1 = char.Torso
for i = 1, 100 do wait(0.03) weld.C0 = CFrame.new(0, -1.5, 0) * CFrame.Angles(0, time()*6, 0) end wait(0.5)
weld:Destroy()
--WHAT I MEANT BY RESETTING NECK WELD --WHAT I MEANT BY RESETTING NECK WELD char.Torso.Neck.Part0 = char.Torso char.Torso.Neck.Part1 = char.Head |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:47 PM |
It did solve my killing problem ! :)
Thank you very much!
However, my head keeps moving after unequip and my arms are stuck in the position they were before unequipping.
Any idea? |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:55 PM |
This works perfectly in Edit mode,
function RemoveWelds() Player.Torso.Neck.Part0 = Player.Torso Player.Torso.Neck.Part1 = Player.Head local weldsInFolder = weldFolder:GetChildren() for i = 0,# weldsInFolder do weldsInFolder[i] = nil end weldFolder:destroy() end
But in online, my arms are stuck and my head keeps moving |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 08:58 PM |
I noticed that the folder did not delete in online mode, but it did in Edit.
Destroy doesn't work in online?.. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 09:10 PM |
Maybe it can help, I noticed that, in this script, the ramrodAttachToHandle is not located in weldFolder when running in Server mode:
function SetWelds() Head = Player:FindFirstChild("Head") LeftArm = Player:FindFirstChild("Left Arm") RightArm = Player:FindFirstChild("Right Arm") Body = Player:FindFirstChild("Torso") Ramrod = script.Parent.Parent.InteractiveParts.Ramrod weldFolder = Instance.new("Folder") weldFolder.Name = "weldFolder" weldFolder.Parent = Player headAttachToBody = Instance.new("ManualWeld") leftArmAttach = Instance.new("ManualWeld") rightArmAttach = Instance.new("ManualWeld") ramrodAttachToHandle = Instance.new("ManualWeld") headAttachToBody.Parent = weldFolder leftArmAttach.Parent = weldFolder rightArmAttach.Parent = weldFolder ramrodAttachToHandle.Parent = weldFolder headAttachToBody.Part0 = Body leftArmAttach.Part0 = Head rightArmAttach.Part0 = Head ramrodAttachToHandle.Part0 = script.Parent.Parent.Handle headAttachToBody.Part1 = Head leftArmAttach.Part1 = LeftArm rightArmAttach.Part1 = RightArm ramrodAttachToHandle.Part1 = Ramrod ramrodAttachToHandle.C0 = CFrame.new(0,0.17,-3) * CFrame.fromEulerAnglesXYZ(math.rad(92),0,0) WalkSequence() end |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 09:17 PM |
I also noticed that in Online mode, the Neck item disappears from the Torso of the player when equipping, which crashed the script because it can't find the Neck...
In studio, the Neck stays there...
I'm a bit confused honestly |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 09:24 PM |
| Yeah, the Motor6D items on which I create a Weld disappear when the weld is created... |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 09:29 PM |
And the exact part of the script that removes them is when I attribute the Part1 of the new created weld:
headAttachToBody.Part1 = Head leftArmAttach.Part1 = LeftArm rightArmAttach.Part1 = RightArm ramrodAttachToHandle.Part1 = Ramrod
-- If I comment these, the 6D stays there, but... I can't do that lel |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 09:30 PM |
Also, if I comment those lines, when I unequip the tool, everything goes back to normal.
But as I said, I can't comment these... It's an important part of my script. |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
| |
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 05 Aug 2016 10:05 PM |
| Is it possible to weld body parts or what? |
|
|
| Report Abuse |
|
|
crate109
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
| |
|