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:
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. :>
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.
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.
I’m also not sure that that would work either for what I’m trying to accomplish.
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.
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