Press E to give a player an item / tool

I’m simply looking to create a script that transfers your equipped tool to another player while the tool is touching them, but it actually transfers when you press E. But unfortunately, I don’t have enough Studio knowledge to code it.

2 Likes

Are you asking for a whole script or the basic structure of what you need to code?

1 Like

You can use a LocalScript to detect the input, use a RemoteEvent to tell the server someone triggered it, and then transfer the tool via the server.

Example (client):

local uis = game:GetService("UserInputService")
local event = game:GetService("ReplicatedStorage"):WaitForChild("EventNameHere")

local function processInput(input:InputObject, processed:boolean)
    if input.KeyCode == Enum.KeyCode.E then
        event:FireServer()
    end
end

uis.InputBegan:Connect(processInput)

Server:

local event = game:GetService("ReplicatedStorage").EventNameHere

local function processEvent(player:Player)
    --do stuff with the tool
end

event.OnServerEvent:Connect(processEvent)
4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.