So bassically I was trying to make it so that when I (which is represented by my UserId) touch the part that this script is in, the part goes transparent, and I can walk through it.
script.parent.Touched:connect(function(hit) if hit.UserId == "34310670" then print 'Hello, EpicLilC' script.parent.Transparency = .5 script.parent.CanCollide = false end end)
How come this script doesn't work?
There are a few problems here.
First off, the "hit" is a BasePart, not a Player. That part could be the handle of an accessory, the Right leg, or anything. You must first check if it has a humanoid, then check if it is a player.
script.parent.Touched:connect(function(hit) if hit.Parent:FindFirstChildOfClass("Humanoid") then -- Checks if it has a humanoid local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- Gets the player associated with the character if plr then -- Make sures it is actually there if plr.UserId == 34310670 then -- Makes sure it has the correct userid print 'Hello, EpicLilC' script.Parent.Transparency = .5 script.Parents.CanCollide = false end end end end)
Second, UserId is an int, not a string, as you put in the code. Lastly, it is Parent, not parent.
Hope this helps!