I am making a script for a door. However, when I try clicking the door it doesn't work. The only signs that its not getting from output are "Loadstring() is not available" and " InsertService cannot be used to load assets from the client." I have no idea what InsertService is talking about.
The script I am making is:
local value = script.Opened local Door = script.Parent local close = script.Parent.Parent.Close local open = script.Parent.parent.Open local opensound = script.Parent.Open local closesound = script.Parent.Close
function myfunction() if value == false then value = true Door.Position = open.Position opensound.Play() elseif value == true then value = false Door.Position = close.Position closesound.Play() end end
script.Parent.ClickDetector.MouseClick:connect(myfunction)
I am aware that for the Loadstring() problem you are supposed to turn on LoadStringEnabled in SSS, but that still will not work. I'm pretty sure InsertService has nothing to do with the script, but I can't tell. I am not very experience in scripting yet, so i might've made a big mistake and just cannot see it.
local value = script:WaitForChild("Opened") local Door = script.Parent local close = Door.Parent:WaitForChild("Close") --Use "Door" instead of script.Parent, since you assigned script.Parent to the "Door" variable. local open = Door.Parent:WaitForChild("Open") local opensound = Door:WaitForChild("Open") local closesound = Door:WaitForChild("Close") local clickDetector = Door:WaitForChild("ClickDetector") function myfunction() if value == false then value = true Door.Position = open.Position opensound.Play() elseif value == true then value = false Door.Position = close.Position closesound.Play() end end clickDetector.MouseClick:Connect(myfunction)
I believe your problem was a typo on line 4, being .parent, which should've been .Parent and also be sure that you should use :WaitForChild() in case the script loads in before anything else, causing an error.