Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script recognize a certain part that shares the same name as others?

Asked by 6 years ago
01local ammoBox = workspace.Box_Ammo
02 
03local GUI = ammoBox.GUI
04local Label = GUI.TextLabel
05local player = game.Players.LocalPlayer
06local magnitude = (player.Character.HumanoidRootPart.Position - ammoBox.Position).Magnitude
07local uim = game:GetService("UserInputService")
08local x = true
09coroutine.wrap(function()
10    while wait() do
11        magnitude = (player.Character.HumanoidRootPart.Position - ammoBox.Position).Magnitude
12        math.floor(magnitude)
13    end
14end)()
15coroutine.wrap(function()
View all 33 lines...

Right, this script is supposed to delete a 'ammoBox' when you press F, and are under 10 studs away from the box. However;

There is more than one ammoBox, and this does it to random boxes. And I don't want to create a new localscript for every single box that I put in. I want it to recognize a box when a player is near it. But I don't know how.

Any help is very appreciated. please leave anything helpful.

ty for reading <3

1 answer

Log in to vote
0
Answered by 6 years ago

Hey, this probably won't work because I'm an idiot at scripting but maybe you could change the part name slightly.

Let's say there's 2 'parts', so you could change it to Part1 and Part2.

Or if you're doing it in the script, and the part has a Parent like Workspace > House > Part you could say it's Parent if you're doing something specific, that way if you're talking about a part in something, you won't change something else random with the same name.

Yeah ..you can try it but it probably won't work because remember I'm really poop at scripting.

0
ty, but I need it to work unanimously with all parts that are . named ammoBox userdetail 1 — 6y
Ad

Answer this question