Hello, devs!

So I was making a concert simulation game. I made it so you are able to grab tool by clicking on it. I had to do like it's not called handle when it's not in player's backpack, so player can't take it by touching it. Then made it so when tool is equipped it renames the "Handl" part to "Handle". Always when I do test, for the first time when I try grabbing microphone tool, it works. (I made script that puts the tool back when you press gui button.) When I try grabbing the microphone for the second time, it doesn't works anymore. Weird. Everything was good until I made it so it renames the part. Every script (There are a lot of scripts for the tool, but only one isn't working.) is working and part is renaming, except for one line in this one script. I hope you can help me out with that.

CODE:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
		if game.Players:FindFirstChild(player.Name).Backpack:FindFirstChild("Microphone") then
	else
		local mic = script.Parent:Clone()
		if mic:FindFirstChild("Handl") then
			mic:FindFirstChild("Handl").Name = "Handle"  -- Line causing problem
			wait()
			mic.Parent = game.Players:FindFirstChild(player.Name).Backpack
			mic:WaitForChild("ClickDetector"):Destroy()
			mic:WaitForChild("Grab"):Destroy()
			mic:WaitForChild("Handle").Anchored = false  -- This line isn't working, because line 6 isn't changing Handle part name.
			mic:WaitForChild("VoicePart").Anchored = false
			wait()
			script.Parent:Destroy()
		end
	end
end)

ERRORS:

Infinite yeld possible on 'Players.ErktikyYT.Backpack.Microphone:WaitForChild("Handle")' line 11

6 comments

0

That's not an error, it's a warning.

0

I know. Always when I post something on Scriptinghelpers I do things like CODE: and ERRORS: so it's just like output.

0

Handle part still isn't getting renamed and that's why anchor don't work.

0

Don't you think having the tool that you click should instead clone the same tool from serverstorage into the players backpack then set its parent to nil?

0

Why cant you just name it handle in-studio or am I missing something

0

I wan't to disable option for people to grab this part by touching it.