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

How do I force a tool into the players hand?

Asked by 8 years ago

Thanks for any help I get.

3 answers

Log in to vote
2
Answered by 8 years ago

Just make the tool's parent the character, because the tools you are holding belong to the character. You can use the Unequipped function so it changes the tools parent automatically. This can reduce lag because you are using an event instead of a loop. You need to add a wait because when you unequip a tool and set the parent back to the character it will error.


Unequipped()

This is an event that fires when a tool is... Unequipped.

local tool = script.Parent

tool.Unequipped:connect(function()
    print("Tool is unequipped")
end)


Final Product

This script is your answer, the other script is an extra.

Tool.Parent = char --Make tool a variable and same with char.

or

char.Humanoid:EquipTool(tool)

Link to Variable


This script will make it so the script will never be able to be removed or unequipped.

--Local Script
local tool = script.Parent
local char = game:GetService("Players").LocalPlayer.Character
game:GetService("RunService").RenderStepped:wait() --Really fast wait. 2x faster than wait().
char.Humanoid:EquipTool(tool)

tool.Unequipped:connect(function()
    game:GetService("RunService").RenderStepped:wait()
    char.Humanoid:EquipTool(tool)
end)


Hope it helps!

0
Don't forget; There is also the 'EquipTool' method of a Player's Humanoid. :) TheeDeathCaster 2368 — 8y
0
Ooh, there is also an UnequipTool method also... Anyway thx. EzraNehemiah_TF2 3552 — 8y
Ad
Log in to vote
-4
Answered by 8 years ago

Well if you are using a giver, which I assume you are you can use this script!

local debounce = false

function onTouch(hit) 
    local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- getting the player from his character
    if player.Character and not debounce then -- checking if the player's character exists and the debounce == false
        local char = player.Character  -- defining character for later use
        debounce = true 
        local weapon = game.Lighting.GEARNAME:clone() 
        weapon.Parent = char -- parenting the weapon to character
        wait(5)
        debounce = false
    end 
end

script.Parent.Touched:connect(onTouch)

Make sure you put this following script inside a Part called "Giver" and put the tool in Lighting, then change the "GEARNAME" part to the name of the gear you want them to have.. Also if you want them to be unable to drop it go to the gear click on it, and un-check the "CanBeDropped" part! This script will automatically equip the weapon when it is give to them.

Log in to vote
-6
Answered by 8 years ago

All you have to do is set the Equipped value to true whenever the player tries to Unequip it like this

function WhatEverYouWantToNameIt ()
script.Parent.Equipped = true
end

script.Parent.Unequipped:connect(WhatEverYouNamedTheFunction)

0
The Property is called Enabled, not Equipped. EzraNehemiah_TF2 3552 — 8y
0
Well i was about to add that this is the script i have for mine and that i may not work due mine being set up differently. Therefore mine is .Equipped purplemetro3421 5 — 8y

Answer this question