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

Module script help how do I fix??

Asked by 9 years ago
12:42:20.458 - Workspace.testModuleScript:11: attempt to index global 'hit' (a nil value)
12:42:20.459 - Stack Begin
12:42:20.460 - Script 'Workspace.testModuleScript', Line 11 - field DoorOpen
12:42:20.460 - Script 'Players.Player1.PlayerGui.Main_V0.03.Main_V0.03', Line 137
12:42:20.460 - Stack End
Error^^
local open = script.Parent.Parent.DoorPart.Open
local close = script.Parent.Parent.DoorPart.Closed

if close.Value == true and open.Value == false then
wait()
print'Open'
testModule.DoorOpen()
else if open.Value == true and close.Value == false then
wait()
print'Close'
testModule.DoorClose()
end
end
^^^^^^Script inside the "door"
local testModule = {}

testModule.DoorOpen = function()
wait()
print"Open"
for i = 1, 4.9, 0.1 do
hit.Parent.DoorPart.CFrame=script.Parent.CFrame*CFrame.new(0.2,0,0)
wait()
wait(WaitTime)
hit.Parent.DoorPart.Open.Value=true
end
end

testModule.DoorClose = function()
wait()
print'Close Function ran'
for i = 1, 4.9, 0.1 do
script.Parent.CFrame=script.Parent.CFrame*CFrame.new(-0.2,0,0)
wait()
wait(WaitTime)
hit.Parent.Parent.DoorPart.Open.Value=false
hit.Parent.Parent.DoorPart.Closed.Value=true
hit.Parent.DoorPart.Closed.Value=true
wait()
end
end

return testModule
^^^^^Module script
This is in a local script its only a bit of code, the bit that has to do with the door. its in player gui.

PLR.Character["Torso"].Touched:connect(function(hit)
if hit.Name == "DoorOpen" then
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
if key == " " then
print'Opened Localscript'
if hit.Parent.DoorPart.Open.Value ~= true and hit.Parent.DoorPart.Closed.Value ~= false then
testModule.DoorOpen()
end
if key == " " then
print'Closed Localscript'
if hit.Parent.DoorPart.Closed.Value ~= true and hit.Parent.DoorPart.Open.Value ~= false then
testModule.DoorClose()
end
wait(5)
hit.Parent.DoorPart.Script.Disabled=true
elseif hit.Parent.DoorPart.Script.Running.Value == true then
return end
end
end)
end
end)

Answer this question