Im trying to create a test tool that destroys another players body part when touched yet its not working and not giving me any errors, Any ideas?
local p = game.Players.LocalPlayer local c = p.Character local x = {"Right Arm", "Right Leg", "Torso", "Left Arm", "Left Leg", "Head"} script.Parent.Touched:connect(function(hit) if hit.Parent ~= c then return end if hit.Parent == x then x:Destroy() end end)
You're actually missing an end on the innermost if statement. Also, your variable names aren't very descriptive. hit.Parent will never == x either, because x is a table. "connect" is deprecated, you should use Connect instead. :)
Instead, I recommend on doing this in a server-script inside game.ServerScriptService:
local part = workspace.Part local debounce = true local childrenToDestroy = {"Left Arm"} part.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then for _, characterChild in pairs(player.Character:GetChildren()) do for _, targetChild in pairs(childrenToDestroy) do if characterChild.Name == targetChild then characterChild:Destroy() end end end end end)
I'm assuming this is what you're trying to do but I'm not quite sure.