I'm trying to make a computer that has a changeable screensaver but it only turns white? Any ideas?
local image = "https://www.roblox.com/library/675254742/Subnautica" script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Parent.Parent.ScreenSaver.MainPart.ScreenSaver.ImageLabel.Image = image end)
I'm a bit of a noob, so please go easy! Thanks.
It's much easier to just not make a variable. This works for me if it doesn't for you, then you must have messed up on line 2.
script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Parent.Parent.ScreenSaver.MainPart.ScreenSaver.ImageLabel.Image = ('rbxassetid://675254741') end)
If you want it to pick a random picture then use the one below.
PictureTable = {} PictureTable [1] = "'rbxassetid://675254741'" PictureTable [2] = "'rbxassetid://000000000'" PictureTable [3] = "'rbxassetid://000000000'" --etc script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Parent.Parent.ScreenSaver.MainPart.ScreenSaver.ImageLabel.Image = (PictureTable[math.random(1, 3)]) --3 is the number of pictures in the table. end)
I feel like what you want is to understand where you went wrong and how to fix it. Seeing as how you say you are noobish
, let me try to explain as much as i can. The rest however, is up to you to research.
In your variable image
, that image "url" is not correct. The url must point to an image you have uploaded to your game or a decal uploaded to roblox. So it must start with rbxassetid://
or rbxgameasset://
. If you are using a decal you have uploaded to the site then you can go to the decal, look at the url on the page, copy the numbers (which is the id) and paste it after rbxassetid://
and use that as the url. Now if you are using an image uploaded to the images folder in your game through studio then use rbxgameasset://
to get the url to the image go to the images Folder then right-click on it and select the option "Copy path to Clipboard" then just paste inside the image variable. If you can't find the Images Folder i'm talking about, it's inside the Game window, to enable it go to View -> Game Explorer.
Once you have changed your image
variable to what i mentioned above, I'm now assuming you have placed this localscript in a SurfaceGui which is inside a Part and the SurfaceGui contains an image label.
Due to not know what event you want to happen for the screensaver to change i'll be assuming you want the user to click on the imageButton which would cause the screensaver to change:
local image = "this will be to what you changed it to above" script.Parent.ImageLabel.MouseButton1Click:Connect(function() script.Parent.imageButton.Image = image end)
That should work, i could be wrong since i'm pretty tired. I'm going to go to sleep now.
The code should've been done like this
local image = "rbxassetid://675254741" script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Parent.Parent.ScreenSaver.MainPart.ScreenSaver.ImageLabel.Image = image end)
Use the ID and put rbxassetid:// before it. It should work fine now unless you misplaced
script.Parent.Parent.Parent.Parent.ScreenSaver.MainPart.ScreenSaver.ImageLabel.Image