Please Help me With my Script

Hello There,

I have This Script Where we are trying to Edit the Stats Through a Panel. What the Script is Meant todo is you Put in a Amount then you put in the players Name But We are Getting a Error saying (Index nil) We are Trying to Defined the Player But Nothing Is Happening.

local Amount = script.Parent.Parent.Amount.Text
local player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:connect(function(player: Player)

if Amount == nil then


script.Parent.Parent.Info.Text = "No Value has Been Entered..."
wait(4)
		script.Parent.Parent.Info.Text = "Enter In the amount"

else
		Amount = script.Parent.Parent.Amount.MoneyAMT.Value
		script.Parent.Text = player.Name
	script.Parent.Parent.Parent.ChangeMoney:FireServer(Amount)


	end
end)

If you have any Suggestions How to Fix This issue Please let Me know!

Official_SimuIation!

Which line of the script is this happening on?

And the error means you’re trying to index a nil value with something

local something = nil
local somethingElse = something.Parent.Parent

-- Error :O

It’s Happening With This Line.
script.Parent.Text = player.Name

This is the error

Here is your problem

script.Parent.MouseButton1Click:connect(function(player: Player)

MouseButton1Click doesn’t return a player variable

local player = game:GetService("Players").LocalPlayer

And you already have a player variable at the start of the script

Solution: Remove the player parameter in the MouseButton1Click

script.Parent.MouseButton1Click:connect(function() -- Fixed

Fully fixed code:

local Amount = script.Parent.Parent.Amount.Text
local player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()

if Amount == nil then


script.Parent.Parent.Info.Text = "No Value has Been Entered..."
wait(4)
		script.Parent.Parent.Info.Text = "Enter In the amount"

else
		Amount = script.Parent.Parent.Amount.MoneyAMT.Value
		script.Parent.Text = player.Name
	script.Parent.Parent.Parent.ChangeMoney:FireServer(Amount)


	end
end)
1 Like