Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ShopGui help? :|

Asked by 8 years ago

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)
0
I added a fix to my answer. User#11440 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
  • 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!

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 ProCoolEXE 27 — 8y
0
I added a fix User#11440 120 — 8y
Ad

Answer this question