Iam new to lua scripting and i want to make script which makes the head transparency to 0.5 who ever touches but this dosent work please HELP!.
Error :- 21:04:53.288 - Place1 was auto-saved to C:/Users/prudhvi/Documents/ROBLOX/AutoSaves/Place_AutoSave_1.rbxl 21:04:53.949 - Workspace.Part.Script:2: attempt to index global 'player' (a nil value) 21:04:53.949 - Stack Begin 21:04:53.950 - Script 'Workspace.Part.Script', Line 2 21:04:53.950 - Stack End
code :- ``player = game.Players.LocalPlayer char = player.Character head = char:FindFirstChild("Head") remove = script.Parent
remove.Touched:connect(function() head.Transparency = 0.5 end)``
LocalPlayer won't work since the localscript is not inside the player
U should use GetPlayerFromCharacter() to find the player
Like this:
remove.Touched:connect(function(hit) --I'm just guessing that remove is the brick local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Finds the player local char = player.Character -- Finds the char char.Head.Transparency = 0.5 --Sets head's transparency to 0.5 end)
I hope this helped ;)