I know this seems like a stupid post because this is simple, but I can’t find a solution to this online.
I will have more than 2-3k parts. These parts will be cloned, but I just don’t want every one of them to have a script. I’m not asking you to give me a working script, but I would appreciate a start!
Well, I havent ever needed this, but I think you can try naming each of these parts something certain, then check if the player’s legs (r6) or feet (r15) touch the named parts.
try this
local partName = "your part name here"
script.Parent.RightFoot.Touched:Connect(function(t)
if t.Name == partName then
--Your code here
end
end)
You could use CollectionService for something like this, give the part a tag then clone it as many times as you would like. I recommend you look it up on Youtube, or on the forums. It’s pretty straightforward and quite easy to use.
This works (on a normal character), but on my character, which has only 1 part (humanoid root part) it doesn’t. Do you know how I could fix this? I put this as a script in StarterCharacterScripts
If you clone all the parts and parent them to a model or folder it becomes ridiculously easy. You can loop through each part on your character and add a touched event. After this you can just check if the part it touched is the child of the cloned model using like hit.Parent == workspace.Clone or whatever and if it is then just hit:Destroy(). Hope this helps I guess.
Edit: This is better than adding a connection to every part because you’re adding a connection to 2-3k parts whereas with this one you’re only adding it to like 10 parts.
Assuming your parts are in a folder in the workspace called like Clone, your code would look something like this:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for _, part in pairs(char:GetChildten()) do
if not part:IsA(“BasePart”) then continue end
part.Touched:Connect(function(hit)
if hit.Parent == workspace.Clone then hit:Destroy() end
end)
end
end)
end)
Edit:
Wrote this on mobile so it will probably error but it’s just a concept.
You would be iterating through 2-3k parts to check if it is close by and it wouldn’t be accurate because it would be generating a sphere instead of a box, so this wouldn’t be a good option.