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

ShopGui help? :|

Ok, so here a problem Here script. This script for shop system. When player clicking button with scirpt = adding item from library of itemids (ServerStorage) with amount item that player wanted. Technically this script adding intvalue with name that is itemid, value is amount items, into folder that setuped by special script. Anyone can help with this? Here scripts, if you need. This its button that adding item

local object = game.ServerStorage
local localplayer = game.Players.LocalPlayer
local folder = localplayer.Items
 script.Parent.Parent.TextButton.MouseButton1Down:connect(function()
	for i, items in pairs(object:GetChildren()) do
		local addeditem = Instance.new("IntValue")
	addeditem.Name = items[1].Value
	addeditem.Value = addeditem.Value + 1
	addeditem.parent = folder
	end
end)

And this script is setup for items

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

game.Players.PlayerAdded:connect(function(player)
	local itemsfolder = Instance.new("Folder")
	itemsfolder.Name = "Items"
	itemsfolder.Parent = game.Players.LocalPlayer
	warn("Player with name like ".. player.Name.. " is ready!")
end)

1 comment

0

I added a fix to my answer.

1 answer

  • First Script,

Local Scripts Can't access Server Storage

Use ReplicatedStorage.

--Local Script
local object = game.ReplicatedStorage
local localplayer = game.Players.LocalPlayer
local folder = localplayer.Items

script.Parent.Parent.TextButton.MouseButton1Down:connect(function()
    for i, items in pairs(object:GetChildren()) do
        local addeditem = Instance.new("IntValue")
    addeditem.Name = items.Value-- tiems isn't a table
    addeditem.Value = addeditem.Value + 1
    addeditem.parent = folder
    end
end)
Move the Item To Replicated Storage. I also added a few more fixes

  • Second Script,

Scripts can't access Local Player.

Don't do that,

--Regular Script
local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
    local itemsfolder = Instance.new("Folder")
    itemsfolder.Name = "Items"
    itemsfolder.Parent = player
    warn("Player with name like ".. player.Name.. " is ready!")
end)
I'm not sure what warn is, but with FE enabled, scripts can't access PlayerGui

Good Luck!

2 comments

0

with second script is normal,but with first still getting error like this: 11:32:23.808 - 1 is not a valid member of IntValue 11:32:23.809 - Script 'Players.Player1.PlayerGui.ScreenGui.ShopGui.ScrollingFrame.TextButton.Script', Line 8 11:32:23.809 - Stack End

0

I added a fix

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