Den_vers
(Den_vers)
July 30, 2023, 11:22pm
#1
Hey, I’ve been having this problem for about 4 days now, it’s starting to get frustrating. Pretty much, I’m sure you guys have all seen the games that have the items on your back, like knife and gun in Murder Mystery 2, and Hammer and Gem in Flee the Facility.
In my game it’s a knife, and I can’t seem to get it working. The script has changed many times, but currently this is how it looks:
task.spawn(function()
player.Character:WaitForChild("UpperTorso")
local weld = Instance.new("WeldConstraint")
weld.Name = "BackKnifeWeld"
local equippedKnife = RS.KnifeResources[player:WaitForChild("Knives"):GetAttribute("Selected")]:FindFirstChildWhichIsA("Tool").Handle:Clone()
equippedKnife.Name = "BackKnife"
equippedKnife:PivotTo(
player.Character.UpperTorso:WaitForChild("BodyBackAttachment").WorldCFrame *
CFrame.fromEulerAnglesYXZ(math.rad(-45), math.rad(-90), 0))
equippedKnife.Parent = player.Character
weld.Part0 = player.Character.UpperTorso
weld.Part1 = equippedKnife
weld.Parent = player.Character
end)
Pretty much this code runs RIGHT after .CharacterAdded()
is fired.
It just doesn’t work though
Here’s what I know:
– It has nothing to do with cloning problems. Nothing.
– It has nothing to do with CFrame math, because I’ve seen it work before.
Any questions, please ask.
Another thing, when you check what the weld is welded to in the explorer, it always says it’s welded to the knife but not the UpperTorso, even though I weld it.
1 Like
Have you tried to find the problem with print statements? Could you explain what makes it “not work?”
Den_vers
(Den_vers)
July 30, 2023, 11:26pm
#3
Yes, sir.
There are no errors in the console.
Den_vers
(Den_vers)
July 30, 2023, 11:28pm
#4
It always works when you spawn, but when you reset it stops.
You need to continuously connect the event each time they spawn. What kind of script is it? Where is the script located?
Den_vers
(Den_vers)
July 30, 2023, 11:31pm
#6
It’s a server script, of course, I hope this problem doesn’t have to do with any network ownership issue, which it probably shouldn’t. But I’m pretty sure you’re only supposed to connect the event once to the player.
Katrist
(Katrist)
July 31, 2023, 12:16am
#7
Is this your entire script?
Den_vers
(Den_vers)
July 31, 2023, 4:01am
#8
no, the actual script is huge.
So, to get things straight, you want to weld a tool on the player’s back?
1 Like
So what exactly is the problem with this?
Den_vers
(Den_vers)
July 31, 2023, 8:26pm
#11
The knife, it works the first time you spawn, but then when you die and respawn it doesn’t.
Katrist
(Katrist)
July 31, 2023, 8:38pm
#12
Tell me what this prints, I just want to make sure .CharacterAdded is being fired:
task.spawn(function()
print("CharacterAdded")
player.Character:WaitForChild("UpperTorso"):WaitForChild("BodyBackAttachment")
print("CharacterLoaded")
local weld = Instance.new("WeldConstraint")
weld.Name = "BackKnifeWeld"
weld.Part0 = player.Character.UpperTorso
local equippedKnife = RS.KnifeResources[player:WaitForChild("Knives"):GetAttribute("Selected")]:FindFirstChildWhichIsA("Tool").Handle:Clone()
equippedKnife.Name = "BackKnife"
equippedKnife:PivotTo(player.Character.UpperTorso.BodyBackAttachment.WorldCFrame * CFrame.fromEulerAnglesYXZ(math.rad(-45), math.rad(-90), 0))
equippedKnife.Parent = player.Character
weld.Part1 = equippedKnife
weld.Parent = player.Character.UpperTorso
end)
1 Like
Den_vers
(Den_vers)
July 31, 2023, 10:27pm
#13
Katrist:
task.spawn(function()
print("CharacterAdded")
player.Character:WaitForChild("UpperTorso"):WaitForChild("BodyBackAttachment")
print("CharacterLoaded")
local weld = Instance.new("WeldConstraint")
weld.Name = "BackKnifeWeld"
weld.Part0 = player.Character.UpperTorso
local equippedKnife = RS.KnifeResources[player:WaitForChild("Knives"):GetAttribute("Selected")]:FindFirstChildWhichIsA("Tool").Handle:Clone()
equippedKnife.Name = "BackKnife"
equippedKnife:PivotTo(player.Character.UpperTorso.BodyBackAttachment.WorldCFrame * CFrame.fromEulerAnglesYXZ(math.rad(-45), math.rad(-90), 0))
equippedKnife.Parent = player.Character
weld.Part1 = equippedKnife
weld.Parent = player.Character.UpperTorso
end)
It prints both. But still there is no knife.