So, as the title suggests, I’m trying to make a script that can weld a part to a R15 player’s right hand after you click a button on the keyboard.
The issue is that I have tried so many different methods to make this work but nothing, half the Enum keycode scripts I attempted to recycle didn’t work how they originally were, and I tried to make about 10 scripts and not one worked.
I tried to find solutions here on the developer forums, nothing even related to my issue. I tried reddit, and you tube, no help. Still nothing happening.
And I forgot to mention this but this is for a vr game, but I will do that after I can get it working outside of VR and just recycle the script. But here is one of the codes I thought would work but didnt.
local playersAllowed = game.Players.ChildAdded
local plr = nil
function onKeyPress(inputObject, gameProcessedEvent)
--ignore
end
for i=1,#playersAllowed do
--ignore
if plr.Name == playersAllowed[i] then
--ignore
end
if inputObject.KeyCode == Enum.KeyCode.Q then
--ignore
local function weldPlayer(player)
local character = player.Character
local RH = character and character:FindFirstChild("RightHand")
if character and RH then
local weld = Instance.new("WeldConstraint")
weld.Part0 = part
weld.Part1 = RH
weld.Parent = part
end
end
part.Touched:Connect(function(hit)
end)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not part:FindFirstChildWhichIsA("WeldConstraint") then weldPlayer(player)
end
end
end
Not gonna lie that script is pretty embarrassing but I tried my best for a builder, just help me revise it.