#Works if I comment out the top line

36 messages · Page 1 of 1 (latest)

lilac pivot
#
local Misc = require(game:GetService("ReplicatedStorage").Misc)

script.Parent.MouseButton1Click:Connect(function()
    if script.Parent.BackgroundColor3 ~= Color3.fromRGB(255, 17, 86) then
        script.Parent.BackgroundColor3 = Color3.fromRGB(255, 17, 86)
        script.Parent.UIStroke.Color = Color3.fromRGB(84, 1, 21)
        Misc:CurrentTrack():Pause()
    else
        script.Parent.BackgroundColor3 = Color3.fromRGB(115, 244, 9)
        script.Parent.UIStroke.Color = Color3.fromRGB(52, 83, 9)
        Misc:CurrentTrack():Play()
    end
end)```If I comment out line 1, the color on the button changes but if I don't have it commented out, nothing happens
lilac pivot
#

nop

dusty urchin
#

Try :WaitForChild() on misc?

pulsar pivot
#

i mean if line 1 is commented how would the line above else work

#

it would give an error tho

dusty urchin
#

ReplicatedStorage:WaitForChild(“Misc”)

lilac pivot
half mirage
#

if yes try commenting the functions for currentrack too

lilac pivot
#

The currenttrack does not pause

#

Which it should

#

But it doesn't because of line 1

half mirage
#

it's probably playing because another script is making it play

#

that's why

#

so it does indeed break the code

half mirage
#

storage

#

and even then you should just do .ReplicatedStorage and not :GetService("ReplicatedStorage")

#

replicatedstorage is one of the services that are by default already accessible by the game

half mirage
#

i've genuinely tested it out myself

#

so it's something else

#

but as i said, everyone one of these services are already accesible by the game

lilac pivot
lilac pivot
half mirage
#

it's like doing 2+2+2+2+2+2+2+2+2+2=20 instead of 2*10=20

lilac pivot
#

Looks more clean in my eyes

half mirage
#

but you're wasting resources in the long run

#

its more optimized to just do game.ReplicatedStorage instead of game:GetService("ReplicatedStorage")

#

plus it's way faster to type as well

pulsar pivot
#

the most optimized thing u can do

#

is get the service

#

and then require in a different line