Hello there!
So, I’m trying to make a unioned box containing 6 parts, and I have a script where when the box is clicked, it fades out. It works perfectly in Studio, but not in-game. I need help!
local Present = script.Parent.Parent
script.Parent.ClickDetector.MouseClick:Connect(function()
for i = 0, 10 do
Present.Union.Transparency = Present.Union.Transparency + 0.1
wait()
end
Present.Union.CanCollide = false
Present.Tag:Destroy()
Present:Destroy()
end)
I would add in :WaitForChild to the local Present = script.Parent, right? Also, I found out that it works when it is in workspace, but I’m trying ot get it to be parented to workspace from server storage when I click a button, and that’s when it breaks.
i dont think you need the waitforchild for local Present = script.Parent.Parent but try putting the object in replicated storage instead and cloning it from there instead of sever storage? i dont use server storage since it sometimes bugs out when i try cloning from there.
I cant debug this as you haven’t provided enough information on the context of your script
Its worth noting that a Server Script, will only run in the following contexts
A descendant of Workspace
A descendant of ServerScriptService
A descendant of Player*
*This behaviour is a bit wacky and is unreliable, it’s best practise outside of tools to use localscripts when dealing with players
Okay I want to suggest something, I’m not saying you should do this but, if you’re using this how I think you’re using this, it will get unmaintable VERY quickly.