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

How would I give a player a tool by script?

Asked by 2 years ago

I am trying to make a part and if you touch it, it will give you a tool.

0
like one that also regens the part when you get the tool? D00M1N 4 — 2y

3 answers

Log in to vote
0
Answered by 2 years ago

you should put the tool inside replicatedstorage, and then you have to clone it and parent it to the player's backpack.

0
just make a simple script that detects if a humanoid touched the part and then clone the tool to his backpack XxdarksidemarcoxX 0 — 2y
0
Find the humanoid is a bad pratice. The best way is using :FindFirstAncestorWhichIsA("Model") on the hit part and try to find if it's a character with GetPlayerFromCharacter a method of the PlayerService NiniBlackJackQc 1562 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Hi I made a tool system for you. https://www.roblox.com/library/10630206924/Tool-System After inserting put your tool in ServerStorage. Then Copy the name of the tool and go to script in the model and enter the name of your tool.

Log in to vote
0
Answered by 2 years ago

You should make a Script inside the Part that is supposed to be touched that Clones your Tool from the ReplicatedStorage into the Players Backpack.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage.Weapons.Sword

script.Parent.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local Character = Hit.Parent
        local Player = Players:GetPlayerFromCharacter(Character)

        if not Player.Backpack:FindFirstChild(Sword.Name) then
            local SwordClone = Sword:Clone()
            SwordClone.Parent = Player.Backpack
        end
    end
end)

Answer this question