Shield is not working

#1

Hello there,

I’ve been getting this weird error in the output for my shield, that I have no idea how to fix. It says "The current identity (2) cannot MakeJoints (lacking permission 1). Does anyone know what I am doing wrong?

Error

image
This is the error
image
This is where the error is located.

What my Shield looks like

image

Code in my Script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local equipped = false
local up = false
local shield = script.Parent.Parent
local handle = shield:WaitForChild("Handle")
---------------------CODE BELOW--------------------------
print("Step0")
player:GetMouse().KeyDown:connect(function(k)
	if not character:findFirstChild("Left Arm") then return end
	if not character:findFirstChild("Torso") then return end
	if not character.Torso:findFirstChild("Left Shoulder") then return end
	local lsh = character.Torso:findFirstChild("Left Shoulder")
	if k == "q" then --Spawns the Shield to the Left Arm
		equipped = not equipped
		up = false
		lsh.Part1 = character["Left Arm"]
		print("Step1")
		if equipped then
			shield = script.Parent
			for n,i in pairs(shield:GetChildren()) do
				if i.Name ~= "Handle" and i:IsA("BasePart") then
					local nw = Instance.new("Weld",i)
					nw.Part0 = shield.Handle
					nw.Part1 = shield.handle
					nw.C0 = shield.handle.CFrame:inverse()
					nw.C1 = i.CFrame:inverse()
				end
			end
			handle.Anchored = false
			shield.Parent = workspace
			print("Step2")
			shield.Parent:MakeJoints()
			local nw = Instance.new("Weld",character["Left Arm"])
			nw.Part0 = character["Left Arm"]
			nw.Part1 = handle
			nw.C1 = CFrame.new()
			nw.Name = "LeftGrip"
		else
			if character["Left Arm"]:findFirstChild("LeftGrip") then
				character["Left Arm"].LeftGrip:remove()
			end
			shield:remove()
			print("Step3")
		end
	elseif k == "e" and equipped then --Raise Shield
		up = not up
		if up then
			lsh.Part1 = nil
			local w = Instance.new("Weld",shield)
			w.Part0 = character.Torso
			w.Part1 = character["Left Arm"]
			w.C1 = CFrame.new(1.2,-.25,0.25) * CFrame.fromEulerAnglesXYZ(math.rad(-75),math.rad(55),0)
		else
			for n,i in pairs(shield:GetChildren()) do
				if i.ClassName == "Weld" then
					if i.Part0 == character.Torso then
						i.Parent = nil
					end
				end
			end
			lsh.Part1 = character["Left Arm"]
		end
	end
end)
0 Likes

#2

You set the parent of the shield to workspace, and then you call :MakeJoints() on the shield’s parent.

workspace:MakeJoints() -- The current identity (2) cannot MakeJoints (lacking permission 1)
1 Like

#3

So at the top I should change “local shield = script.Parent.Parent” to “local shield = workspace.Parent”?

0 Likes

#4

You should figure out what you want it to do, which I doubt is call :MakeJoints() on workspace (espcially since that throws an error). Figure out what you want to call it on.

1 Like

#5

What I’m trying to get the shield to do is spawn on my left arm, by pressing the key “Q”.

Then by pressing the key “E” it should raise the shield.

0 Likes

#6

After you check the equip flag, you dynamically build the shield’s welds (all welded to the handle). In my opinion, I would have this done already with the model, since you also introduced a few bugs.

  • Unequipping and re-equiping would generate the welds again.
  • The welds aren’t even generated correctly, both part0 and part1 are the handle

Next, you parent the shield to workspace, my assumption is it should be the character; would you want a shield instance “floating” in the workspace?

Then you call MakeJoints on the shield’s parent (workspace as of now). Here’s the definition of :MakeJoints() from the wiki.

Description: Goes through all parts contained in the Model. If any part’s side has a SurfaceType that can make a joint it will create a joint.

So I assume that’s not at all what you want, you can remove that line.

Finally, you create a weld for the hand. As far as I can tell, that’s correct. Though, using instance.new(name, parent) and supplying the parent is bad practice; you should initalize all the properties before setting the parent. Also you set the C1 to the default value.

You can read about the instance.new problem here

1 Like

#7

You don’t want to involve any form of MakeJoints() for this. Workspace is a Model, but it overrides MakeJoints() with one that requires a list of parts. But like with Model:MakeJoints() it is meant for making automatic welds between parts that have things like studs and inlets or glue surfaces. This is old tech you likely want nothing to do with. You just need to weld the shield to the character’s arm, as you’re trying, but your real problem is in here somewhere:

local nw = Instance.new("Weld",i)
nw.Part0 = shield.Handle
nw.Part1 = shield.handle
nw.C0 = shield.handle.CFrame:inverse()
nw.C1 = i.CFrame:inverse()

Firstly, change this to Instance.new(“Weld”) or Instance.new(“Motor6D”) without the second argument. Set the parent of the weld last, after you set all the CFrames.

Secondly, either Part0 or Part1 should be getting set to i, no? This loop probably isn’t welding the handle to itself, because it’s spelled with capital H in one place and lowercase in the other, but even so, I doubt welding the handle to itself repeatedly is what you want anyways.

Lastly, I don’t think your C0 and C1 settings are what you want either. It might look right, but if it were a Motor6D and you set an angle on it, you’d get some weird results. You don’t normally want these CFrames in world space you want them to be in the reference frames of Part0 and Part1.

3 Likes