01 | local ammoBox = workspace.Box_Ammo |
02 |
03 | local GUI = ammoBox.GUI |
04 | local Label = GUI.TextLabel |
05 | local player = game.Players.LocalPlayer |
06 | local magnitude = (player.Character.HumanoidRootPart.Position - ammoBox.Position).Magnitude |
07 | local uim = game:GetService( "UserInputService" ) |
08 | local x = true |
09 | coroutine.wrap( function () |
10 | while wait() do |
11 | magnitude = (player.Character.HumanoidRootPart.Position - ammoBox.Position).Magnitude |
12 | math.floor(magnitude) |
13 | end |
14 | end )() |
15 | coroutine.wrap( function () |
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
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.