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. Thanks for your help.

PinoRisi03

0
Errors please Feroxidus 83 — 4y
0
Line 07: Does keycode.keycode not throw any errors? ConsteIeo 63 — 4y
0
no errors are displayed in the script PinoRisi03 -3 — 4y
0
is this script a local script or server script? TrippeDanieI 21 — 4y
View all comments (2 more)
0
capitalize the second "KeyCode" Flasker917 21 — 4y
0
It's in a Script. PinoRisi03 -3 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

So..., I've tried the script on another world. An error is displayed 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. :)

Thank you

Ad

Answer this question