Hello all, I am creating a World-Base multiplayer RPG Adventure Zombie game, and I've run into a problem!
My pop-up shop gui won't work! I can get the GUI to pop-up when the player touches the appropriate brick, but the ImageButtons in the SHOP GUI do NOT function as coded, and I cannot see as to why! The error I sometimes get(not all the time), is that "Chips is not a valid member of IntValue", But the code, without errors, creates the proper folder, and "Chips" IS a proper IntValue according to the test!
Here's my Shop UI code:
script.Parent.MouseButton1Click:Connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Glock")
local price = 250
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
if stats.Chips.Value>=price then
stats.Chips.Value = stats.Chips.Value - price
local cloned = item:Clone()
cloned.Parent = player.Backpack
cloned.Parent = player.StarterPack
end
end)
Here is my leaderstats code:
game.Players.PlayerAdded:Connect(function(plr)
local fold = Instance.new("Folder", plr)
fold.Name = "leaderstats"
local val = Instance.new("IntValue", fold)
val.Name = "Chips"
end)
while true do
wait(5)
for i, v in pairs (game.Players:GetChildren ()) do
if v:FindFirstChild ("leaderstats") ~= nil then
if v.leaderstats:FindFirstChild("Chips") ~= nil then
v.leaderstats.Chips.Value = v.leaderstats.Chips.Value + 1000
end
end
end
end

14 comments
ur telling the leaderboard script that if it cant find leaderstats or chips inside leaderstats then it should increase the value of chiips
Okay... I'd just like the Leaderstats to show as "Chips". It doesn't even do that. Would deleting lines 09-18 allow that to happen? Just as a test? Or not?
You seem to have posted the wrong snippet. This code should work perfectly fine.
It doesn't. In my game, nothing shows! I have no clue as to why!
Like I have a GUI(Which works will the K/D leaderstats so ik it works) that is supposed to show the amount of chips, like it does K/D. But, it doesn't. And it says because the script doesn't work. Like there's an error. So, I have no clue why.
Can you post the code that "can get the GUI to pop-up when the player touches the appropriate brick"? And do post the error message
The sop UI and Popup Works, so do the buttons in the UI. As I tested it on a different game I made with a working leaderstats that doesn't seem to work in this game. So it's not that.
The error message says that "Chips isn't a proper value of intvalue" or something along those lines.
Please post the exact error. After revising the code 10+ times, there is nothing wrong with it.
Yes there is, running leaderstats deductions and cloning objects on client!?! You should be firing a remote event and handling all of the stuff on the server.
How would I do this? RemoteEvents for my ChracterUI seemed to work.
How would I do this? RemoteEvents for my ChracterUI seemed to work.
In your Shop UI code, after you declare the stats variable on line 6, declare a new variable titled chips. Try this: chips = stats:FindFirstChild("Chips"). Your error seems to be caused by not being able to find "Chips" in leaderstats. Like others have said, you should also do this server sided with a remote event.
Alright! I don't know EXACTLY how to do that. If you answer with that, I can accept it. Give you the points.