I am stuck on why this code is nil when it works perfectly fine on another local script? All of these scripts are in StarterPlayerScripts. The error message is Players.Zeppelin0330.PlayerScripts.LocalScript:1: attempt to index field 'Character' (a nil value)
if game.Players.LocalPlayer.Character.Beep.Value == 0 then -- this line states that character is a nil value
game.Players.LocalPlayer.PlayerGui.ScreenGui.Dave.Grenade.Text = "x 2"
end
game.Players.LocalPlayer.Character.Beep.Changed:Connect(function()
print("why?")
if game.Players.LocalPlayer.Character.Beep.Value == 1 then
game.Players.LocalPlayer.PlayerGui.ScreenGui.Dave.Grenade.Text = "x 1"
else if game.Players.LocalPlayer.Character.Beep.Value == 0 then
game.Players.LocalPlayer.PlayerGui.ScreenGui.Dave.Grenade.Text = "x 0"
end
end
end)
this is the working one and it is similar to the one above but works?!
game.StarterGui.ScreenGui.Dave.Visible = true
local throwPower = 100
local debounce = true
local canThrow = true
local player = game.Players.LocalPlayer
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(KeyPressed)
if KeyPressed == "g" and debounce == true and player.Character.Beep.Value < 2 then
player.Character.Beep.Value = player.Character.Beep.Value + 1
print("it works")
if player.Character.Team.Value == 2 then
debounce = false
print("hi")
local Back = player.Backpack
game.Workspace.StickGrenade:Clone().Parent = player.Backpack
player.Character.Humanoid:EquipTool(Back.StickGrenade)
player.Character.Humanoid.Died:Connect (function()
end)
end
wait(1.5)
end
wait(2)
debounce = true
end)
local player = game.Players.LocalPlayer
game.Workspace.Meep.Why.Changed:Connect(function()
print("hi")
game.Players.LocalPlayer.PlayerGui.ScreenGui.Dave.Visible = true
end)

3 comments
whats the exact error message?
and which line is the error coming from?
I state that line 1 is the error line and the error it states is Players.Zeppelin0330.PlayerScripts.LocalScript:1: attempt to index field 'Character' (a nil value)