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

Door not opening once key is in inventory?

Ok this is pretty basic but idk i just can't figure it out. i'm making a door that opens when you get a key is in your inventory. But for some reason it acts like there is no key in my inventory. Any solutions?

workspace.MetalDoor.Door.ClickDetector.MouseClick:Connect(function(player)
	if player.Inventory:FindFirstChildWhichIsA('Model') then
		workspace.MetalDoor.Locked.Value = false
		workspace.MetalDoor.Door.CFrame = CFrame.new(-13.582, 4.005, 34.154)
		workspace.MetalDoor.Door.Orientation = Vector3.new(0, 50.42, 0)
		workspace.MetalDoor.Open:Play()
		wait(2)
		workspace.MetalDoor.Close:Play()
		workspace.MetalDoor.Door.CFrame = CFrame.new(-10.471, 4.005, 34.633)
		workspace.MetalDoor.Door.Orientation = Vector3.new(0, -43, 0)
	else
		workspace.MetalDoor.Bang:Play()
		wait(.5)
		workspace.MetalDoor.Bang:Play()
	end
	if workspace.MetalDoor.Locked.Value == false then
		workspace.MetalDoor.Locked.Value = false
		workspace.MetalDoor.Door.CFrame = CFrame.new(-13.582, 4.005, 34.154)
		workspace.MetalDoor.Door.Orientation = Vector3.new(0, 50.42, 0)
		workspace.MetalDoor.Open:Play()
		wait(2)
		workspace.MetalDoor.Close:Play()
		workspace.MetalDoor.Door.CFrame = CFrame.new(-10.471, 4.005, 34.633)
		workspace.MetalDoor.Door.Orientation = Vector3.new(0, -43, 0)
	end
end)

1 answer

I'm not very sure about this, but try to check the player's Character

put this part in the weapon or whatever

local char = game.Players.Localplayer.Character
if script.Parent.Parent == char then
--rest of the script

you might have to use a RemoteEvent

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