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

How do I make it so when this brick gets hit, another brick's script gets enabled?

How do I make it so when this brick gets hit and after all of its properties change, the next brick's script gets enabled.

Context: Brick 1 is named "Front" and Brick 2 is named "FD1". Also, the script for "FD1" is disabled in properties. This is for a crash physics script.

All of these parts are grouped together.

Script inside Front/Brick1

local DentSpeed = 40
local id = 1

script.Parent.Touched:Connect(function(part)
	if part.Parent == script.Parent.Parent then
		wait()
	else
		end

		local Seat = script.Parent.Parent.VehicleSeat
		if Seat.Velocity.Magnitude >= DentSpeed then
			wait(.25)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
script.Parent.Parent.FD1.Transparency = 0
script.Parent.Parent.FD1.CanCollide = true
Seat.Sound.Volume = 2
	Seat.Sound.MaxDistance = 1000
Seat.Sound:Play()

wait(5)

script.Parent.Parent.FD1.script.Disabled = false

wait (1)
script.Parent:Destroy()

end
		end)

^ Basically it changes some of the properties in the next brick, so when the next brick is hit it can change properties in the next brick.

Script inside FD1

local DentSpeed = 40
local id = 1

script.Parent.Touched:Connect(function(part)
	if part.Parent == script.Parent.Parent then
		wait()
	else
	end
	
	local Seat = script.Parent.Parent.VehicleSeat
		if Seat.Velocity.Magnitude >= DentSpeed then	
				wait(.25)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
script.Parent.Parent.FD2.Transparency = 0
script.Parent.Parent.FD2.CanCollide = true

Seat.Sound.Volume = 2
	Seat.Sound.MaxDistance = 1000
Seat.Sound:Play()

end
		end)

2 answers

This is an example:

ActivatorBrick = script.Parent.ABrick
EventBrick = script.Parent.EBrick

ABrick.Touched:connect(function()
EBrick.(Your function here)

end)

I'm not 100% sure of it's functioning, but it should be something like the one above !

2 comments

0

I have to do all that just to enable another brick's script?

0

Kind of

Add this in your code

local otherBrick = --where ever the brick with the script is
local brick = script.Parent --brick that will be touched

brick.Touched:Connect(function(hit)
	--Make sure to check that a player has touched, I am just going to add the other code for now
	otherBrick:FindFirstChildOfClass("Script").Disabled = false
end)

3 comments

0

":Disabled"

0

um

0

Didn't notice the ":Disabled" been working with ":WaitForChild()"s alot, lol fixed it.

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