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

How do i fix 'Attempt to call a nil value'?

I wanted to make a script for an admin panel that, when you press +100 it adds 100 credits to the targeted player's credits intValue, but i get the output Attempt to call a nil value?

local currentTarget = script.Parent.Text
local player = game.Players.LocalPlayer
script.Parent.Parent.okButton.MouseButton1Click:Connect(function()
script.Parent.Parent.playerNameCn.Text = currentTarget
	script.Parent.Parent.playerTarget.Visible = false
	script.Parent.Parent.playerNameCn.Visible = true
script.Parent.Parent.p100.MouseButton1Click:Connect()
	game.Players[currentTarget].leaderstats.Credits.Value = game.Players[currentTarget].leaderstats.Credits.Value + 100
end)
script.Parent.Parent.back.MouseButton1Click:Connect(function()
	script.Parent.Parent.playerNameCn.Text = "nameHolder"
	script.Parent.Parent.playerNameCn.Visible = false
	script.Parent.Parent.playerTarget.Visible = true
end)


1 answer

✓ Accepted answer

Which line?

I see 2 options, first is that you should use :WaitForChild() in case script executes faster than the part loads, second is that the part might not exist and you defined it wrong.

EDIT: i think im wrong, nil value is that you are trying to get property or function that does not exist, for example: Part.Visible does not exist so you can not define it.

3 comments

0

Still the same output, and i said that there is no output error, just attempt to call a nil value.

0

Its an error.

0

Check if you have defined all instances right.

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