An issue with grabbing an image

I’ve been following a tutorial and I’m trying to grab an image so that when i click on a certain button (GUI) that specific one appears. Unfortunately however, I have this issue. Here it is:

And here’s the script that broke.

script.Parent.Activated:Connect(function()
	local info = script.Parent.Parent.Parent.Parent.Parent.Info
	info.PuppyName.Text = script.Parent.Parent.PuppyName.Text
	info.Description.Text = script.Parent.Parent.Description.Value
	info.ImageLabel.Image = script.Parent.Parent.ImageLabel.Image
	info.Visible = true
end)

If you need any more information, let me know! In case this helps, here’s a picture of my work StarterGUI and ServerStorage. I’m a pretty beginner scripter so hopefully this is an easy fix. :>

Edit: I believe that the 2nd half of the code in line 5 is what is causing this issue. (script.Parent.Parent.ImageLabel.Image)

This should be script.Parent.Parent

1 Like

Okay so I did that but it gave me this error.


(Edited)

Sorry i was looking at wrong script… try instead script.Parent.Parent.Info

I think you were right the first time, since it seems to of worked this time and now I have another error. (the one above edited)

Is this script the local script or the server script in your hierarchy there?

Is it the one in the close button or in the scrolling frame?

It’s a local script.

I’m not exactly sure what you meant by this, sorry lol.

Where exactly is this local script located…i see two local scripts in your picture there.

Oh! It’s this one. In the ServerStorage.

And in case this helps as well, here’s where the Beagle came from. It’s just in a folder. I’m not sure if I need to grab the image from here or something else.

image

Ok scrap what i said before then… you will need to grab the Info frame from the PlayerGui.

I believe that would work if I just use the script I originally had? Since it worked early until this “Image Label” part.

script.Parent.Activated:Connect(function()
local info = script.Parent.Parent.Parent.Parent.Parent.Info
info.PuppyName.Text = script.Parent.Parent.PuppyName.Text
info.Description.Text = script.Parent.Parent.Description.Value
info.ImageLabel.Image = script.Parent.Parent.ImageLabel.Image
info.Visible = true
end)

Sorry didn’t mean to leave you hanging im on mobile and its difficult to scroll around and read it all properly i thought it was a simple location fix but its a bit more than that.

It honestly still might be, and no worries lol. I’ve been thinking but could it have to do with script.Parent.Parent.ImageLabel.Image? Specifically, The ImageLabel.Image part. In the actual puppies, the images are stored in decals, but if I try to change it to something such as Decal.Texture, it sends an error again. Although, this could be totally different because it’s trying to get the image from a frame.

I think you might have done a typo.
Instead of doing Info.ImageLabel = script.Parent.Parent.ImageLabel
you did info.ImageLabel.Image = script.Parent.Parent.ImageLabel.Image
a small detail you probably did not notice is that the frame name is ‘Info’ and in the script, you wrote ‘info’(No capital I). Even a small grammar error can lead to the problem. Hope it helped you.

1 Like

The local script should not be in ServerStorage. It should be in Workspace or StareterGUI

I think the info with a lowercase i was part of the variable. And I’ll go ahead and try putting the script in StarterGUI.

local info = script.Parent.Parent.Parent.Parent.Parent.Info

I’m also not sure that that would work either for what I’m trying to accomplish.
image

Every time one of the puppies is clicked, the puppies find it’s specific description, name, and image from the values I put in the “Puppies Folder” shown above.

Now, I’m not sure if the script needs to be different to find a Decal in the “Puppies Folder” or the script needs to find it somewhere else. Either way, wherever it’s looking right now in my script, it’s clearly not there.

image

When I click on one of these puppies in my GUI, I want it to find the image for that specific puppy and paste it on the right there. Like this.

Actually the LocalScript is not supposed to be in ServerScriptService you will have to add a Script instead. But also not the script will function for the whole server and not one player.

Edit: You can add the script in the button. Also make sure the puppies folder is in ReplicatedStorage. Here is an example of the script:

--ReplicatedStorage--
local ReplicatedStorage = game.ReplicatedStorage -- the location of ReplicatedStorage
local Puppies = ReplicatedStorage.Puppies
local PuppyName = Puppies.Beagle--This is just an example--
--Main--
local button = script.Parent
--Script--
button.MouseButton1Click:Connect(Function() --checks if the player has clicked on the puppy.--
button.PuppyImage.ImageID = PuppyName.Decal.ImageID--I would recommend adding a ImageLabel which shows the description of the puppy--
button.PuppyDescription.text = PuppyName.Description.Value--I would recommend adding a text label which shows the description of the puppy--
button.PuppyDifficulty.Text = PuppyName.Difficulty.Value--I would recommend adding a text label which shows the difficulty of the puppy--
end)

Note that decals can’t be added to StarterGUI but ImageLabels, ImageButtons or ViewportFrame can be added to StarterGUI

I can give modded script if you can show where the puppy description, image, etc will be visible

Alright, I’ll go try that, thanks for your help! I just didn’t think that because in the video tutorial I watched it was in ServerScriptService.