Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this error show up in my transformation script whenever I reactivate it?

Code:

local tracked = false
local armtrans = game.ReplicatedStorage.Transformations.RightHandTrans:Clone()
local lowarmtrans = game.ReplicatedStorage.Transformations.RightLowerArmTrans:Clone()
local weld = Instance.new("Weld")
local wiel = Instance.new("Weld")

script.Parent.Diref.OnServerEvent:Connect(function(plr, Tracker)
	local trackerdb = false
	local tries = plr.Data.Tries.Value
	if tracked == false then tracked = true else tracked = false end
	if tracked == true then
	local Char = plr.Character or plr.CharacterAdded:wait()
	local hum = Char.Humanoid
	
	armtrans.Parent = Char.RightHand
	armtrans.CFrame = Char.RightHand.CFrame
	weld.Part0 = armtrans
	weld.C0 = armtrans.CFrame:inverse()
	weld.Part1 = Char.RightHand
	weld.C1 = Char.RightHand.CFrame:inverse()
	weld.Parent = armtrans
	armtrans.Anchored = false
	
	lowarmtrans.Parent = Char.RightLowerArm
	lowarmtrans.CFrame = Char.RightLowerArm.CFrame
	wiel.Part0 = lowarmtrans
	wiel.C0 = lowarmtrans.CFrame:inverse()
	wiel.Part1 = Char.RightLowerArm
	wiel.C1 = Char.RightLowerArm.CFrame:inverse()
	wiel.Parent = lowarmtrans
	lowarmtrans.Anchored = false
	
	print("Hi")
	else 
		lowarmtrans:Destroy()
		armtrans:Destroy()
		weld:Destroy()
		wiel:Destroy()
		print("Hello")
	end

	while true do
		if tracked == false then return end
		if trackerdb == true then return end
		trackerdb = true
		print("Eo")
		plr.Data.Tries.Value = plr.Data.Tries.Value + 30
		wait(2)
		trackerdb = false
		end
end)

In this code everything is working fine until I try to reactivate the code. The second time I make the transformations appear this error occurs:

09:38:22.579 - The Parent property of RightHandTrans is locked, current parent: NULL, new parent Workspace

I really don't have a clue on what's happening. Somebody please save me.

1 answer

✓ Accepted answer

#Reasoning


This is because your’re trying to set the Parent of something that you destroyed. This means it no longer has a Parent, as it doesn’t exist anymore... Locked means it’s Parent is inaccessible, again, this is because there is no Parent, ergo NULL.


#Solution


:Destroy() is predominantly for the use of destroying and Object as you don’t need anymore. If you want to remove something and put it back, set it’s Parent to nil, so it will appear as it’s gone, though just isn’t situated anywhere, once reparented, it’ll be useable again. - Do this for lines 35-38.


Hope this helps, don’t forget to accept this answer if so!

2 comments

0

Oh wow, thanks bruv. This really helped.

0

No problem! Happy to save ya;)

This discussion is preserved as it was. New answers, comments, and votes are closed.