Hello!
Let's cut to the chase, I am attempting to make a keycard system in which you have to click the keycard scanner with a keycard in your backpack.
(I did this instead of having to check for a keycard in their character, because apparently clickdetectors don't work with tools on)
Now, there are no errors or anything. Even with the keycard in the playres backpack, it will always deny access (play a denied sound and not open the door) and I seriously need help.
Here's the code:
slider = script.Parent.Model.touchz
acceptedsound = script.Parent.accepted
declinedsound = script.Parent.declined
local openClick = game.Workspace.DoorButton1.fart.ClickDetector
local tweenService = game:GetService("TweenService")
local Properties = {
Position = Vector3.new(-198.327, 12.12, 71.057)
}
local TweenInfoo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local tween = tweenService:Create(script.Parent,TweenInfoo,Properties)
local Properties2 = {
Position = Vector3.new(-198.287, 4.39, 71.057)
}
local TweenInfooo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local tween2 = tweenService:Create(script.Parent,TweenInfooo,Properties2)
slider.ClickDetector.MouseClick:Connect(function(player)
if player.Backpack:FindFirstChild("Keycard") then
tween:Play()
acceptedsound:Play()
else
declinedsound:Play()
end
end)
This is probably what is wrong with the script:
slider.ClickDetector.MouseClick:Connect(function(player)
if player.Backpack:FindFirstChild("Keycard") then
tween:Play()
acceptedsound:Play()
else
declinedsound:Play()
end
end)
https://cdn.discordapp.com/attachments/1076530438912356392/1076817600698396682/image.png
A picture of the tools in the backpack, in case that would help.
Thank you in advance for helping!
edit: forgot to include .MouseClick

3 comments
What is openClick being used for? Add some debugging with print statements.
does it play the declined sound?
I fixed it not playing. The only thing is, when you are holding the tool clicking the keycard slider doesn't work.