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

Help with a weapon Safety?

Im trying to have weapons require a safety function, script is below with attached Gyazo of the scripts location in the model.

http://gyazo.com/481b196c3c4e91e8d1ceb9a9a7d5d9bd

C = script.Parent.Parent.Safety
local p = script.Parent:GetChildren()

function Toggle()
	if C.Value == true then
		open()
	elseif C.Value == false then
		close()
	end		
end

function open()
	for i = 1, #p do
		if p[i]:FindFirstChild("Flangs") then 
			p[i].Flangs.Transparency = 0
		end
	end
end

function close()
	for i = 1, #p do
		if p[i]:FindFirstChild("Flangs") then 
			p[i].Flangs.Transparency = 1
		end
	end

end

C.Changed:connect(Toggle)

1 comment

0

Perhaps use UserInput() instead?

1 answer

Put your Toggle function below the open and close functions ad see if that helps. As it stands now, it won't work due to order of operations in the script - the Toggle function has not visibility to your open and close functions unless they're placed before it.

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