So I have this script that puts a Gui into a player when touching a part and when I went to go test it today I got "attempt to index nil with 'Parent'" I literally changed nothing in the script and it was just working :/
local market = game:GetService("MarketplaceService") local part = script.Parent local GUI = game.ReplicatedStorage.GunShop local function onTouched(hit) local newboii = GUI:Clone() local humanoid = hit.Parent:WaitForChild("Humanoid") if humanoid then local char = hit.Parent local sPlayer = game.Players:GetPlayerFromCharacter(char) local putinto = sPlayer:WaitForChild("PlayerGui") if market:UserOwnsGamePassAsync(sPlayer.UserId,8810446) then newboii.Parent = putinto -- this is the line it errors at else market:PromptGamePassPurchase(sPlayer,8810446) end end end part.Touched:Connect(onTouched)
Hey! Maybe try printing the name of the GUI that you are cloning. It could be that the GUI isn't actually being cloned.
This might work
local market = game:GetService("MarketplaceService") local part = script.Parent local GUI = game.ReplicatedStorage.GunShop local function onTouched(hit) local humanoid = hit.Parent:WaitForChild("Humanoid") if humanoid then local char = hit.Parent local sPlayer = game.Players:GetPlayerFromCharacter(char) local putinto = sPlayer:WaitForChild("PlayerGui") if market:UserOwnsGamePassAsync(sPlayer.UserId,8810446) then GUI:Clone().Parent = putinto--put the clone gui here and made it clone into "putinto" else market:PromptGamePassPurchase(sPlayer,8810446) end end end part.Touched:Connect(onTouched)
If this doesn't work let me know and I can try and find another solution