Log in to vote

how do make a gun(or other bricks) attached to the player? [closed]

Asked by 11 months ago

think of if you played phantom forces and you hit the deploy button, you automatically have the gun up and equipped. I don't like using tools for this because it feels wrong. I have only done basic scripting, and I cant find anything on how to do this.

Make a framework? Vexuss_Recon -14 — 11mo

Closed as Not Constructive by hiimgoodpack, lukeb50, abnotaddable, CootKitty, DeveloperSolo, Void_Frost, and Goulstem

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
Answered by
Goulstem 7832 Badge of Merit Moderation Voter Administrator Community Moderator
11 months ago

Using the PlayerAdded and CharacterAdded events, you can weld objects onto the character model each time they spawn.


        --Wait for the HumanoidRootPart
        local root = char:WaitForChild("HumanoidRootPart");
        --Create the object to weld
        local part ="Part");
        part.Size =,3,3);
        part.CFrame = root.CFrame;
        part.Transparency = .5;
        part.BrickColor ="Bright red");
        part.CanCollide = false;
        --Create the weld
        local w ="Weld");
        w.Part0 = part;
        w.Part1 = root;
        w.Parent = part;
        part.Parent = char;

To use this for a "gun", you would want to weld to the character's arm. "Shooting" is a matter of detecting user input using a LocalScript, and using Remotes to transfer the information to the server.

Log in to vote
Answered by 11 months ago

Making your first First Person Shooter?

local cam = workspace.CurrentCamera local RepS = game:GetService("ReplicatedStorage") local RunS = game:GetService("RunService") local model = RepS:WaitForChild("Model"):Clone() for i,v in pairs (model:GetChildren()) do if v:IsA("BasePart") then if v ~= model.PrimaryPart then local weld ="Weld") weld.Part0 = model.PrimaryPart weld.Part1 = v weld.C0 = model.PrimaryPart.CFrame:inverse() weld.C1 = v.CFrame:inverse() weld.Name = v.Name weld.Parent = model.PrimaryPart end end end

model.Parent = cam

RunS.RenderStepped:Connect(function() model:SetPrimaryPartCFrame(cam.CFrame*,-2,-2)) end)

This isn't my script but it'll work for your needs!

Best Regards.

CODEBLOCK!!! abnotaddable 862 — 11mo
"This isn't my script but it'll work for your needs!" So, is this why so many people are amused by how people make bots? hiimgoodpack 1835 — 11mo