Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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.

2 comments

1

That was the answer, but there is one problem. loadstring() is still unavailable, even with Loadstringenabled turned on.

0

Strange.

This discussion is preserved as it was. New answers, comments, and votes are closed.