Im trying to make a tool when the letter E is pressed it teleports an part into the player.
This was my script but it didnt work:
local UIS = game:GetService(“UserInputService”)
local plr = game.Players.LocalPlayer
local keycode = Enum.KeyCode.E
local tool = script.Parent
local rock = game.Workspace.Rock
local equipped = false
local plrPos = game.Players.LocalPlayer.Vector3UIS.InputBegan:Connect(function(key, gp)
if key.KeyCode == keycode then
if UIS:GetFocusedTextBox() == nil then
if equipped == true then
rock.Position = Vector3.new(plrPos)
end
end
endtool.Equipped:Connect(function()
equipped = true
end)
end)tool.Unequipped:Connect(function()
equipped = false
end)
Thanks for reading!