Need help in codding

I am still new to roblox lua
i was trying to make shop

local rs = game:GetService("ReplicatedStorage")
local buytool = rs:WaitForChild("buytool")


buytool.OnServerEvent:Connect(function(plr,tool)
	
	print(tool.Name)


		if plr.Character:FindFirstChild(tool.Name) then

			return

		end



		if plr.Backpack:FindFirstChild(tool.Name) then

			return

		end

	if plr.leaderstats.kills.Value >= tool.Price.Value then
		

	
			local giveTool = rs.ShopItems[tool.Name]:Clone()

			giveTool.Parent = plr.Backpack

			local giveTool = rs.ShopItems[tool.Name]:Clone()

			giveTool.Parent = plr.StarterGear

		end
	
end)
	local leader = Instance.new("Folder")
	leader.Name = "leaderstats"
	leader.Parent = plr
	
	local kills = Instance.new("IntValue")
	kills.Name= ("Kills")
	kills.Parent = leader
	kills.Value = 500
	
	
	local xp = Instance.new("IntValue")
	xp.Name= ("xp")-- change ("Cash") 
	xp.Parent = leader
	xp.Value = 500
	
end)

error

Server - buyscript:7
  23:05:40.608  kills is not a valid member of Folder "Players.xprogamerdfg.leaderstats"  error is on line script:24

You named the variable kills Kills, So in line 24:

if plr.leaderstats.Kills.Value >= tool.Price.Value then

Would be the correct.

Edit: Be sure to always Double check your scripts

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.