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

I am trying to script but it keeps saying "Loadstring() is not available," what do I do?

Asked by 4 years ago

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.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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.

1
That was the answer, but there is one problem. loadstring() is still unavailable, even with Loadstringenabled turned on. Pyro_dood 31 — 4y
0
Strange. Utter_Incompetence 856 — 4y
Ad

Answer this question