You can write your topic however you want, but you need to answer these questions:
I want the script to get to the player’s parent
-
What is the issue?
I’m trying to make a local for player, the script should detect the player when you sit in the seat, But i get this error that says "Attempt to index nil with ‘Parent’ " and I don’t see any issue with this so I’m trying to look for a fix -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Well, I’m new to scripting so i don’t know much about this error.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local par = script.Parent.Parent
local Load = script.Parent.headL:Clone()
local Anyone = script.Parent.Parent.Occupant
local smokes = script.Parent.Parent.Parent.Parent.Parts.Mesh
local player = game.Players:GetPlayerFromCharacter(Anyone.Parent) -- The error source
Load.Parent = player.Character
Load.Disabled = false
Load.light1.Value = smokes.lights.light1
Load.light2.Value = smokes.lights.light2
Load.light3.Value = smokes.lights.Clight
Load.Sound.Value = smokes.LightUse
par.r1.OnServerEvent:Connect(function(plr)
script.light1.Value:Play()
script.light1.Value.Transparency = 0
script.light1.Value.headG.Enabled = true
script.light2.Value.Transparency = 0
script.light2.Value.headG.Enabled = true
script.light3.Value.Transparency = 0
end)
par.r2.OnServerEvent:Connect(function(plr)
script.light1.Value.Transparency = 1
script.light1.Value.headG.Enabled = false
script.light2.Value.Transparency = 1
script.light2.Value.headG.Enabled = false
script.light3.Value.Transparency = 1
end)
par.r3.OnServerEvent:Connect(function(plr)
script.Sound.Value:Play()
script.light1.Value.Transparency = 0
script.light1.Value.headG.Enabled = true
script.light2.Value.Transparency = 0
script.light2.Value.headG.Enabled = true
script.light3.Value.Transparency = 0
end)
par.r4.OnServerEvent:Connect(function(plr)
script.light1.Value.Transparency = 1
script.light1.Value.headG.Enabled = false
script.light2.Value.Transparency = 1
script.light2.Value.headG.Enabled = false
script.light3.Value.Transparency = 1
end)