Script won't work, even though there's no errors

  1. What i wanna make (or already made) - I created a checkerboard floor with two scripts, one for white tiles, which would turn them (smoothly) black overtime, and same for the black tiles but reversed, so it creates this really cool static-y effect (the time it takes from a tile to go from a color to another is random, so each tile is basically a different shade of grey most of the time)

  2. The issue - It was really laggy, since every tile had a copy of their appropriate script, so i ended up with a ton of scripts that were the same, which made the game laggy and the scripts a pain to edit, so I decided to make it so that there would only be two scripts in charge of changing the colors of the tiles (the white tiles had a script that turned them into white and vice versa) but I just can’t get it to work, I’m attempting this via tags, the scripts also show no errors so I have no idea what’s wrong.

  3. Attempts - I tried tutorials and another forum posts, however none of them worked.

Here I will be showing only the white tiles, since if it works i can basically just make the black tiles work too, no need for both.

local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")

local TweeningInformation = TweenInfo.new(
	math.random(10,15),
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut,
	100,
	true,
	0
)

workspace.misc["randomized floor"].lighter:GetChildren() partProperties = {
	Color = Color3.fromRGB(99, 95, 98)
}

local Tween = TweenService:Create(workspace.misc["randomized floor"].middle.lighter:GetChildren(),TweeningInformation,partProperties)
Tween:Play()

for i, model in pairs(CollectionService:GetTagged("light")) do
	
end
2 Likes

To clarify, the “color changing” part used to work before, it’s just now that i added the tags (and modifications to support said tags) that it doesn’t

You are calling TweenService with an array of objects (i.e. the outcome of :GetChildren()), however tweenservice only takes a single instance.

Try replacing

local Tween = TweenService:Create(workspace.misc["randomized floor"].middle.lighter:GetChildren(),TweeningInformation,partProperties)
Tween:Play()

with

for _, child in ipairs(game.Workspace.misc["randomized floor"].middle.lighter:GetChildren()) do
    local Tween = TweenService:Create(child, TweeningInformation,partProperties)
    Tween:Play()
end

alright i’ll try that, thanks!

nope, didn’t work, here’s how it’s organized, dunno if that’ll help
image
image

The code you provided earlier has it going ["randomized floor"].middle.lighter, but the screenshot provided doesn’t have the .middle. part. Is this discrepancy related to the issue?

oh my god i don’t know how i overlooked that

if this is the cause then it means that all of these hours trying to fix it were basically wasted

basically before the tag approach it used to be organized in a different way, but i had to change it

this seems to work

local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")

local TweeningInformation = TweenInfo.new(
	math.random(10,15),
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut,
	100,
	true,
	0
)

workspace.misc["randomized floor"].lighter:GetChildren() partProperties = {
	Color = Color3.fromRGB(99, 95, 98)
}

for _, child in ipairs(game.Workspace.misc["randomized floor"].ligther:GetChildren()) do
	local Tween = TweenService:Create(child, TweeningInformation,partProperties)
	Tween:Play()
end

for i, model in pairs(CollectionService:GetTagged("light")) do
	
end

this worked, i just had to remove the middle part lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.