So there's this part called "LightSource". When you click it, it disappears and produces light around the torso of the character that is clicking it. This script didn't work:
local Player = game.Players.LocalPlayer local LightSource = game.Workspace.LightSource local Mouse=Player:GetMouse() Mouse.Button1Down:connect(function() if Mouse.Target and Mouse.Target.Name == 'LightSource' then if (Player:findFirstChild("Torso") ~= nil) then local light = Instance.new("PointLight") light.Parent = Player light.Range = 15 end if (Player:findFirstChild("Torso") == nil) then end LightSource:Remove() end end)
Your problem appears to be that you're trying to grab the player themselves instead of their character. When you acquire LocalPlayer, you're getting their information for Players which isn't where their character will be. That can be found in the Workspace as a model named the same as the player.
I know what you're thinking, but instead of finding them via game.Workspace
, you can locate their character with game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer local Character = Player.Character -- This should allow for you to locate the actual character to the player. local LightSource = game.Workspace.LightSource local Mouse=Player:GetMouse() Mouse.Button1Down:connect(function() if Mouse.Target and Mouse.Target.Name == 'LightSource' then if (Character:findFirstChild("Torso") ~= nil) then local light = Instance.new("PointLight") light.Parent = Character light.Range = 15 end if (Character:findFirstChild("Torso") == nil) then end LightSource:Remove() end end)
Side note: In the future, you can block lines of code like I did in the text editor by highlighting the text and clicking the little Lua symbol at the top of the text box.