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

What script is for a animated light and door connected to one button? [CLOSED]

OK, I have a button that is connected to the function of opening a door via grouping the parts together. But I also need to get the button to activate another script connected with another model that has the duty of turning on a spinning animated light. I am stumped and I am asking help as I cannot find any answer to my question. [The button does have a ClickDetector and keep in mind that I am new to the idea of a toggle tool as a BoolValue]

I have attempted at grouping the button-door model and Emergency-Light model into one bigger model and separated the button-door model and Emergency-Light model inside of the bigger model and failed. I tried many more attempts, but to explain each one would be like writing multiple essays.

I currently do not have a script that I can try to find that seems to connect the button to activating another script and need help. I am wondering if it can be added to the Button-door model script. Thanks for everyone that attempted to help me whether failed or not in the end. Here is the script for the button-door model.


open = false

door1 = script.Parent.Parent.Parent.Door1

local TweenService = game:GetService("TweenService")

local part = script.Parent

 
local tweenInfo = TweenInfo.new(24,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local Door1Open = {CFrame = door1.CFrame + door1.CFrame.lookVector * 37}

local Door1Close = {CFrame = door1.CFrame }

local Open1 = TweenService:Create(door1,tweenInfo,Door1Open)

local Close1 = TweenService:Create(door1,tweenInfo,Door1Close)


script.Parent.MouseClick:connect(function()
if open == false then
Open1:Play()

wait(4)
open = true
else
Close1:Play()

wait(4)
open = false

end

end)

The script for the animated light.

sp=script.Parent

bulb=sp:WaitForChild("Bulb")
part1=sp:WaitForChild("Part1")
light1=part1:WaitForChild("SpotLight")
part2=sp:WaitForChild("Part2")
light2=part2:WaitForChild("SpotLight")
toggle=sp:WaitForChild("Toggle")


function updatetoggle()
	bulb.BrickColor=(toggle.Value and BrickColor.new("Really red")) or BrickColor.new("Mid gray")
	light1.Enabled=toggle.Value
	light2.Enabled=toggle.Value
end


toggle.Changed:connect(updatetoggle)
updatetoggle()





rate=1/30
rps=1
currentrotation=math.random()

while true do
	wait(.3)
	while toggle.Value do
		wait(rate)
		currentrotation=currentrotation+(rps*rate)
		part1.CFrame=((bulb.CFrame*CFrame.Angles(0,math.pi*2*currentrotation,0))*CFrame.Angles(0,0,math.pi*.5))*CFrame.new(0,0,part1.Size.z*.5)
		part2.CFrame=((bulb.CFrame*CFrame.Angles(0,math.pi*2*(currentrotation+.5),0))*CFrame.Angles(0,0,math.pi*.5))*CFrame.new(0,0,part2.Size.z*.5)
	end
end

1 answer

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