Hi, why doesn't my door open?
local db = false local open = script.Parent.Open local ind = script.Parent.Tuer script.Parent.CardScanner.Scanner.Touched:Connect(function(p) if db == false then db = true if p.Parent:FindFirstChild("12345") ~= nil then if open.Value == false then local f = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0) for i = 0,1,0.1 do local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f,i) script.Parent.Tuer:SetPrimaryPartCFrame(cfm) wait() end open.Value = true wait(1.5) --- How long the door will stay open local f2 = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0) for i = 0,1,0.1 do local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f2,i) script.Parent.Tuer:SetPrimaryPartCFrame(cfm) wait() end open.Value = false end else print("Keycard wurde nicht akzeptiert oder erkannt") script.Parent.CardScanner.RingLight.BrickColor = BrickColor.new("Really red") wait(1.5) script.Parent.CardScanner.RingLight.BrickColor = BrickColor.new("Parsley green") end db = false end end)
This script with the keycard reader is working. But this script with the 'Press E to interact' won't work.?
local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart") local UIS = game:GetService("UserInputService") local Tuer = script.Parent.Tuer local open = script.Parent.Open UIS.InputBegan:Connect(function(keycode) if keycode.keycode == Enum.KeyCode.E then if(Door.Position - HumanoidRootPart.Position).magnitude < 15 then wait() if open.Value == false then local f = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0) for i = 0,1,0.1 do local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f,i) script.Parent.Tuer:SetPrimaryPartCFrame(cfm) wait() end open.Value = true wait(1.5) --- How long the door will stay open local f2 = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0) for i = 0,1,0.1 do local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f2,i) script.Parent.Tuer:SetPrimaryPartCFrame(cfm) wait() end open.Value = false end else end end end)
"Tuer" means "Tür", i.e. door [--- It's german Can you help me? The door should open when the player presses "E" within a radius of 15.
Its a script.
There
s one Error in the Output:
Workspace.Zauntore.Tor.Script:1: attempt to index nil with 'Character' - Server - Script:1 Stack Begin - Studio Script 'Workspace.Zauntore.Tor.Script', Line 1 - Studio - Script:1 Stack End - Studio
I once wrote it in a LUA box because otherwise the paragraphs would obscure I hope this can help you find the problem.
PinoRisi03
On this part right here, you stated keycode twice.
UIS.InputBegan:Connect(function(keycode) if keycode.keycode == Enum.KeyCode.E then