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)

2 comments
the very first thing that comes to mind when i look at the code is that(at line 6) it creates a new gui clone without identifying whether it is touching a player or not, so that would create alot of unnecessary cloned gui's in your game
oh yeah I did have if putinto:FindFirstChild("GunShop") then return end and I thought that was causing the issue but it wasn't I just forgot to add it back in