#if player holds a certain tool in his hand then

1 messages · Page 1 of 1 (latest)

solar ridge
#

i need to make a code that if the player holds a tool then something will happen, can someone help me?

weak lotus
#

ok

#

what do you want it to do

#

or do you just want the raw connection

solar ridge
#

when i hold a block called sand(its a tool) and u press e i want that u will get another tool and the send will get taken out

weak lotus
#

do you just want the raw connection

#

or do you want a functioning script

true bloom
#

is it my reading comprehension or i just dont understand what youre trying to say

solar ridge
solar ridge
#

so i want it to get taken and the player will get another item

feral eagle
#

just do script.Parent.Equipped:Connect(function()

lucid valveBOT
#

studio** You are now Level 2! **studio

feral eagle
#

fym doesnt work broski

solar ridge
#

what

#

it doesnt work

#

i wont only the sand tool to work

#

this works with any tool

feral eagle
#

what are u talking abt

#

could u explain with mroe detail

solar ridge
#

you put sand, wait 10 second and get clay

feral eagle
#

i've never played grow a garden

solar ridge
feral eagle
#

okay so put a local script into the tool

solar ridge
feral eagle
#

a local one

#

it's called "LocalScript"

solar ridge
feral eagle
#

bro its not my fault ur an idiot

lucid valveBOT
#

studio** You are now Level 10! **studio

feral eagle
#

im tryna be nice man

#

it should be blue and called local script

solar ridge
feral eagle
#
local UIS = game:GetService('UserInputService')

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E and script.Parent.Parent:FindFirstChild("Humanoid") then --Checks if the key that the player pressed was E and if the tool is being held out.
        wait(10)
        
    end
end)

here i wrote this out for you

#

where is the other tool that will be replaced at

#

replicated storage/

#

?

solar ridge
feral eagle
#

after the if statement put this

local char = script.Parent.Parent
wait(10)
local newTool = game:GetService("ReplicatedStorage").TOOLNAME:Clone()
newTool.Parent = game.Players:GetPlayerFromCharacter(char).Backpack
#

and replaced toolname with the name of the tool

#
local UIS = game:GetService('UserInputService')

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E and script.Parent.Parent:FindFirstChild("Humanoid") then
        local char = script.Parent.Parent
        wait(10)
        local newTool = game:GetService("ReplicatedStorage").TOOLNAME:Clone()
        newTool.Parent = game.Players:GetPlayerFromCharacter(char).Backpack
    end
end)

this is it all put together

feral eagle
#

did u wait 10 seconds

solar ridge
#

wait

#

yeah doesnt work

#

wait

feral eagle
#

is there an error

solar ridge
#

but do you know how to stack tools?

feral eagle
#

np Thumbs

#

wdym stack tools

solar ridge
#

thanks

sacred bison