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

Why isn't the function working?

Once the player presses and holds shift I want it to repeat and make the selection box fade and come back and repeat until they drop it or it hits 100 Its funny that I could code harder things but i fail at things like this :c


local ExoSkeleton = create{"Model", Parent = character, Name = "Skeleton"}
for i,v in pairs(character:GetChildren()) do
	print("checking for parts")
	if v:IsA('Part') and v.Name ~= "Head" then
		create{"SelectionBox", Parent = ExoSkeleton, Name = "Outline", Transparency = 1, Adornee = v}
	end
end

local power = create{"NumberValue", Parent = player, Value = 0, Name = "Power"}

while charging == false do
	wait()
	Exo = ExoSkeleton:GetChildren()
	for i,v in pairs(Exo) do
		if v:IsA("SelectionBox") then
			if power.Value == 100 then
				v.Transparency = 0
			else
				x =  math.random(70,100)
				v.Transparency = x*0.01
			end
		end
	end			
end


while wait() do
mouse.KeyDown:connect(function(key)--i was in the middl of making the keydown function that checks what key it is and how long its being pressed
if string.byte(key) == 017 or string.byte(key) == 016 then
	charging = true
	 power.Value = power.Value +1
	while wait() do
		Exo = ExoSkeleton:GetChildren()
		for i,v in pairs(Exo) do
			if v:IsA('SelectionBox') then
				for i = 1,100 do
					wait(0.5)
					v.Transparency = i*0.01
				end
				
			end
		end
	end
end
end)
end
while wait() do
mouse.KeyUp:connect(function(key)
if string.byte(key) == 017 or string.byte(key) == 016 then
	charging = false
end	
end)
end

1 answer

I would suggest using

ExoSkeleton = Instance.new("Model")
Exoskeleton.Parent = character
Exoskeleton.Name = "Skeleton"
-- do the same using Instance.new as shown above for the other times you use "create"

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