Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help! attempt to index nil with 'Data'?

My script dont work because it attempt to index nil with Data? here script

local debounce = false
local summon = false
local UIS = game:GetService("UserInputService")


UIS.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then return end
	
	if Input.KeyCode ==  Enum.KeyCode.Q and Player.Data.HasStand.Value == true then
		if summon == false then
		
			summon = true
			print("summoned the stand")
			game.ReplicatedStorage.Jojo:WaitForChild("SummonStand"):FireServer()
			script.Parent:WaitForChild("Equip").Value = true
		elseif summon == true then
			print("destroyed the stand")
			summon = false
			game.ReplicatedStorage.Jojo:WaitForChild("DestroyStand"):FireServer()
			script.Parent:WaitForChild("Equip").Value = true
		end
	end
end)


if Input.KeyCode ==  Enum.KeyCode.Q and Player.Data.HasStand.Value == true then

that is the line with the error i think

7 comments

0

Do you ever define 'Player' ?

0

Yes

0

but it still dont work and i try with 'Players'

0

Can you edit your question with the code where Player is defined? Your error means Player is nil, so something must be up with that part.

0

ok

0

I still don't see it defined anywhere. When I say 'define' it means where you initiate the variable, somewhere should say something like: local Player = game.Players.LocalPlayer

0

o

1 answer

game.Player.PlayerAddded:Connect(function(player)
	
	local data = Instance.new("Folder")
	data.Name = "Data"
	data.Parent = player
	
	
	local hasStand = Instance.new("BoolValue")
	hasStand.Name = "HasStand"
	hasStand.Value = false
	hasStand.Parent = data
	
	local standName = Instance.new("StringValue")
	standName.Name = "StandName"
	standName.Parent = data
	
end)

There the Data in server script service

When i press q it put the error there it say Players.superplayer1453.Backpack.Summoning:9: attempt to index nil with 'Data'

1 comment

0

What kind of answer is this?

This discussion is preserved as it was. New answers, comments, and votes are closed.