Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get a script know what a player is holding?

so, I have this script:

local TweenService = game:GetService("TweenService")

local door = workspace.Door
local doorRoot = door.PrimaryPart

local DoorSwingInfo = TweenInfo.new()

local DoorSwingTween = TweenService:Create(doorRoot, DoorSwingInfo, {
	CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(95),0)
})

game.Workspace.Door.ProximityPrompt.Triggered:Connect(function(Player)
	if Player:WaitForChild("Backpack"):FindFirstChild("Key") then
		game.Workspace.Door.ProximityPrompt.Enabled = false
		
		DoorSwingTween:Play()
	end
end)	

and my problem is when I hold the key and I open the door with the proximityprompt it doesn't work, it only works when i do not hold it. and I probably know it's because the "WaitForChild("Backpack"), that's why its not working... but what should I put instead of "Backpack", since "Hand" doesn't work.

Thanks!

1 answer

✓ Accepted answer
if Player:WaitForChild("Backpack"):FindFirstChild("Key") or Player.Character:FindFirstChild("Key") then

end

This discussion is preserved as it was. New answers, comments, and votes are closed.