Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't my door open when I press E?

Asked by 4 years ago

Hi, why doesn't my door open?

01local db = false
02local open = script.Parent.Open
03local ind = script.Parent.Tuer
04 
05script.Parent.CardScanner.Scanner.Touched:Connect(function(p)
06    if db == false then
07        db = true
08        if p.Parent:FindFirstChild("12345") ~= nil then
09            if open.Value == false then
10                local f = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
11                for i = 0,1,0.1 do
12                    local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f,i)
13                    script.Parent.Tuer:SetPrimaryPartCFrame(cfm)
14                    wait()
15                end
View all 34 lines...

This script with the keycard reader is working. But this script with the 'Press E to interact' won't work.?

01local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
02local UIS = game:GetService("UserInputService")
03local Tuer = script.Parent.Tuer
04local open = script.Parent.Open
05 
06UIS.InputBegan:Connect(function(keycode)
07    if keycode.keycode == Enum.KeyCode.E then
08 
09    if(Door.Position - HumanoidRootPart.Position).magnitude < 15 then
10    wait()
11    if open.Value == false then
12                local f = script.Parent.Tuer.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
13                for i = 0,1,0.1 do
14                    local cfm = script.Parent.Tuer.PrimaryPart.CFrame:Lerp(f,i)
15                    script.Parent.Tuer:SetPrimaryPartCFrame(cfm)
View all 31 lines...

"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. Theres one Error in the Output:

1Workspace.Zauntore.Tor.Script:1: attempt to index nil with 'Character'  -  Server  -  Script:1
2  Stack Begin  -  Studio
3  Script 'Workspace.Zauntore.Tor.Script', Line 1  -  Studio  -  Script:1
4  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

1 answer

Log in to vote
0
Answered by 4 years ago

On this part right here, you stated keycode twice.

1UIS.InputBegan:Connect(function(keycode)
2    if keycode.keycode == Enum.KeyCode.E then
Ad

Answer this question