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

How do you make ONLY ONE person have a certain gear in game?

Asked by 9 years ago

I know this isn't a "request site" but im terrible at scripting, please can someone help with this?

2 answers

Log in to vote
-1
Answered by 9 years ago

Here SCRIPT 1 (PUT IN WORKSPACE)

T = Instance.new("Tool")
T.Parent = math.Random(game.Players.Player.Backpack)
T.Name = "LazerGun"--Change lazergun to whatever you want but this is the name for the awnser
H = Instance.new("Part")
H.Name = "Handle" --DON'T change this to whatever you want
H.Parent = LazerGun
H.Transparency = 1

LOCAL SCRIPT PUT IN TOOL (NOT HANDLE)

local tool = script.Parent
local user

--when the tool is equipped
tool.Equipped:connect(function(mouse)
   --store the character of the person using the tool
   user = tool.Parent 

   --when the left mouse button is clicked
   mouse.Button1Down:connect(function() 
       --make and do a hit test along the ray
       local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)
       local hit, position = game.Workspace:FindPartOnRay(ray, user)

       --do damage to any humanoids hit
       local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
       if humanoid then
           humanoid:TakeDamage(30)
       end

       --draw the ray
       local distance = (position - tool.Handle.CFrame.p).magnitude
       local rayPart = Instance.new("Part", user)
       rayPart.Name          = "RayPart"
       rayPart.BrickColor    = BrickColor.new("Bright red")
       rayPart.Transparency  = 0.5
       rayPart.Anchored      = true
       rayPart.CanCollide    = false
       rayPart.TopSurface    = Enum.SurfaceType.Smooth
       rayPart.BottomSurface = Enum.SurfaceType.Smooth
       rayPart.formFactor    = Enum.FormFactor.Custom
       rayPart.Size          = Vector3.new(0.2, 0.2, distance)
       rayPart.CFrame        = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)

       --add it to debris so it disappears after 0.1 seconds
       game.Debris:AddItem(rayPart, 0.1)
   end)
end)
Ad
Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

Sir, please attempt to make scripts. This is absolutely not a request site, and we encourage all users to at least make a attempt. If you need help scripting you've got multiple resources.

Many of your questions appear to be requests, and this is not a request site. Please make a attempt at your scripts. Thank you.

Answer this question