Old roblox model respawn selectionbox effect


also the toggleselectionboxoff() never is called so the selection boxes never turn off. to combat this i did
local goal = {Color = BrickColor.Random().Color, ToggleSelectionBoxOff(Vehicle)} but nothing happens and there are no errors

1 Like

Change the selectionbox’s Color to SurfaceColor3

I’ll make a quick example and send it. There is also an issue of the tween not doing anything because it thinks it’s already at the goal color.

nuh uh
image

edit: ok fine

1 Like

{Color3=BrickColor.Random().Color}

ok pog doing what i was told worked and there no no errors anymore @SanctuaryIX and the goal thing happens so the selection boxes turn off

but how do i make it change color like in the video, currently it goes from one shade of blue to another, but i want to make it loop between blue and red (and purple because purple wants to fit in)

1 Like

Here is an example model which will tween:

TweenModel.rbxm (3.8 KB)

If you wish to use it for selection boxes, pass the selectionbox as the part and use
goal.SurfaceColor3 instead of goal.Color

you assign chosen colors in a table

local colorlist = {
Color3.new(1,0,0),--Red
Color3.new(0,0,1)--Blue
}
local index = 1
local function ToggleSelectionBox(Vehicle)
	for i, v in pairs(Vehicle.BodyKit:GetDescendants()) do
		if v:IsA('BasePart') then
			local SelectionBox = Instance.new('SelectionBox')
			SelectionBox.Parent = v
			SelectionBox.Adornee = v
            spawn(function()
  			 while wait(5) do
				local TweenService = game:GetService("TweenService")
				local tinfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
				SelectionBox.Color = Color3.new(0,0,1)
				local goal = {Color = colorlist[index]}
				local tween = TweenService:Create(SelectionBox, tinfo, goal)
				tween:Play()
                if index==#colorlist then index=1 else index+=1 end
			 end
           end)
		end
	end
end

lol it only opens roblox studio

It’s a model. Drag and drop it into the workspace or right click workspace and click import from file


ok trying to do this atm

1 Like

It worked fine for the model I sent. You implemented it wrong. By the way that video is not helpful at all. We are here to help you, and you could at least try to make it easier.

1 Like

the video is the code @Angrybirdcharacter provided in post 19

Heyo, so I suggest looking up “Old Roblox” in the toolbox, I remember there are a few good classic looking Roblox Scripts.

Alright, sorry for the long reply but this is because you are setting the color everytime in the while loop so tweening the color doesnt work as expected

local TweenService = game:GetService([==[TweenService]==])
local animation = TweenInfo.new(1,Enum.EasingStyle.Linear)
local colorlist = {
Color3.new(1,0,0),--Red
Color3.new(0,0,1)--Blue
}
local index = 1
local function ToggleSelectionBox(Vehicle)
	for i, v in pairs(Vehicle.BodyKit:GetDescendants()) do
		if v:IsA('BasePart') then
			local SelectionBox = Instance.new('SelectionBox')
			SelectionBox.Parent = v
			SelectionBox.Adornee = v
            spawn(function()
  			 while true do
				local goal = {Color = colorlist[index]}
				local tween = TweenService:Create(SelectionBox, animation, goal)
				tween:Play()
                if index==#colorlist then index=1 else index+=1 end 
                tween.Completed:Wait() -- no need while wait to determine the length of tween animation
                
			 end
           end)
		end
	end
end

if i was you i wouldn’t use tweenservice and instead use math.sin and math.cos with tick() to synchronize all the parts

game:GetService("RunService").Heartbeat:Connect(function()
       script.Parent.SelectionBox.Color3 = Color3.new(math.sin(tick()*4),0,math.cos(tick()*4));
end);

result:

3 Likes

how do you know a color3 value like this

End up into blue or red? very specific math there


Parts outta sync

tried your code like this:

local TweenService = game:GetService([==[TweenService]==])
local animation = TweenInfo.new(1,Enum.EasingStyle.Linear)
local colorlist = {
	Color3.new(1,0,0),--Red
	Color3.new(0,0,1)--Blue
}
local index = 1
local function ToggleSelectionBox(Vehicle)
	for i, v in pairs(Vehicle.BodyKit:GetDescendants()) do
		if v:IsA('BasePart') then
			local SelectionBox = Instance.new('SelectionBox')
			SelectionBox.Parent = v
			SelectionBox.Adornee = v
			spawn(function()
				while wait(15) do
					game:GetService("RunService").Heartbeat:Connect(function()
						script.Parent.SelectionBox.Color3 = Color3.new(math.sin(tick()*4),0,math.cos(tick()*4))
					end)
				end
			end)
		end
	end
end

1 Like

you used the wrong selectionbox instance

also:

please do not use multiple heartbeat events for all the selectionboxes, make 1 event that controls them all

dont use spawn, use coroutines instead

i wouldnt recommend using tweenservice for looped animations like this

why are you putting it on a while wait(15) loop??? the heartbeat is already looping the animation

image
woah

1 Like