Client Parts of a model

I have a script where if you click any part of the model, a GUI would appear asking to buy it, it, when yes is clicked the image they want to upload goes on the surface of the part, (already scripted). The problem is the GUI appears but you cannot upload any decal ID, nor does the TextLabel get updated. It also works for every single part, the GUI should only appear when you click the one you own. What may the issue be?
LocalScript:

local decalparts = workspace.DecalParts
local player = game.Players.LocalPlayer
local EP = player:FindFirstChild("leaderstats1")
local points = EP:FindFirstChild("ElitePoints")
local Owns = script.Parent.Frame.Owns
local guiFrame = script.Parent.Frame
local Frame = script.Parent.Decal
local yes = script.Parent.Frame.Yes

for _, part in next, decalparts:GetChildren() do
   part.ClickDetector.MouseClick:Connect(function()
   	guiFrame.Visible = true
   	
   	if Owns.Value then 
   	Frame.Visible = true
   		guiFrame.Visible = false
   	end
local decal = part.Decal
local event = game:GetService("ReplicatedStorage"):WaitForChild("imagedec")
local text = script.Parent.Decal.imageid
script.Parent.Decal.imageupload.MouseButton1Down:Connect(function()

		local textid = text.Text
	
	event:FireServer(textid)
end)
end)
end
   	
yes.MouseButton1Down:Connect(function()
   	if points and points.Value >= 10
   	then
   		points.Value = points.Value - 10
   		Owns.Value = true
   		script.Parent.Frame.Visible = false
   		part.SurfaceGui.TextLabel.Text = player.Name .. "'s Decal"
   	end
end)

Workspace:
Part

Surfa

No need to repost.

At first glance, a few problems:

local text = script.Parent.Decal.imageid should be local text = script.Parent.Decal.Texture

local text = script.Parent.Decal.imageid
And then doing: local textid = text.Text will error.

You could do:
TextLabel.Text = text instead. I’m not 100% sure what you’re trying to do but you need to proof read. Also, did you get any errors in your output?
View your output by clicking here:

I got one error

 Infinite yield possible on 'ReplicatedStorage:WaitForChild("imagedec")'

That means that in ReplicatedStorage, you don’t have any instance named imagedec

1 Like

Yes it was named imagedes instead :man_facepalming:

Normally when you call WaitForChild you pass in a number as a second argument to be the amount of seconds to wait. If that time passes without finding the item the function will return nil. If you don’t use the second argument and the item is not found it will give that warning.

2 Likes

Another error I now have is

Players.reteyetet.PlayerGui.buy.LocalScript:36: attempt to index global 'part' (a nil value)