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

sell gui in local script and if i sell, players dont see it, how to make it in normal script?

this is where is remote event

local repsto = game:GetService("ReplicatedStorage")
local sellEvent = repsto:WaitForChild("Eventos").SellEvent

and this is my sell script

local sellitem = script.Parent.Parent.SellItem
local itemprice = script.Parent.Parent.ItemPrice
local sellbut = script.Parent
local player = game.Players.LocalPlayer
local inventory = player:WaitForChild("Inventory")
local leaders = player:WaitForChild("leaderstats")
local money = leaders:WaitForChild("Money")
local backpack = inventory:FindFirstChild("BackPack")

sellbut.MouseButton1Click:Connect(function()
	if sellitem.Text == "Coal" and inventory.Coal.Value >= 1 then
		local nice = inventory.Coal.Value * 10
		money.Value = money.Value + nice
		backpack.Value = backpack.Value - inventory.Coal.Value
		inventory.Coal.Value = inventory.Coal.Value - inventory.Coal.Value
	elseif sellitem.Text == "Gold Ore" and inventory.GoldOre.Value >= 1 then
		local nice = inventory.GoldOre.Value * 100
		money.Value = money.Value + nice
		backpack.Value = backpack.Value - inventory.GoldOre.Value
		inventory.GoldOre.Value = inventory.GoldOre.Value - inventory.GoldOre.Value
	elseif sellitem.Text == "Iron Ore" and inventory.IronOre.Value >= 1 then
		local nice = inventory.IronOre.Value * 50
		money.Value = money.Value + nice
		backpack.Value = backpack.Value - inventory.IronOre.Value
		inventory.IronOre.Value = inventory.IronOre.Value - inventory.IronOre.Value
	else
		print("fail")
	end
end)

i dont know how to use remote events :D

1 comment

0

This would be sort of difficult to explain in an answer I recommend that you follow a video or 2 and mess around with them a little bit.

2 answers

Make sure it's a serverscript. You can't give a player cash on the client side.

here is the code for the a normal script

local sellitem = script.Parent.Parent.SellItem
local itemprice = script.Parent.Parent.ItemPrice
local sellbut = script.Parent

sellbut.MouseButton1Click:Connect(function(plr)
local inventory = plr:WaitForChild("Inventory")
local leaders = plr:WaitForChild("leaderstats")
local money = leaders:WaitForChild("Money")
local backpack = inventory:FindFirstChild("BackPack")
    if sellitem.Text == "Coal" and inventory.Coal.Value >= 1 then
        local nice = inventory.Coal.Value * 10
        money.Value = money.Value + nice
        backpack.Value = backpack.Value - inventory.Coal.Value
        inventory.Coal.Value = inventory.Coal.Value - inventory.Coal.Value
    elseif sellitem.Text == "Gold Ore" and inventory.GoldOre.Value >= 1 then
        local nice = inventory.GoldOre.Value * 100
        money.Value = money.Value + nice
        backpack.Value = backpack.Value - inventory.GoldOre.Value
        inventory.GoldOre.Value = inventory.GoldOre.Value - inventory.GoldOre.Value
    elseif sellitem.Text == "Iron Ore" and inventory.IronOre.Value >= 1 then
        local nice = inventory.IronOre.Value * 50
        money.Value = money.Value + nice
        backpack.Value = backpack.Value - inventory.IronOre.Value
        inventory.IronOre.Value = inventory.IronOre.Value - inventory.IronOre.Value
    else
        print("fail")
    end
end)

If you need more help Dm me on discord cancle5#0035

2 comments

0

Don't use a remote event like that since it's very easy for a exploiter to get inf cash.

0

Yes ik but how to make sellinng

Script.parent.mousebutton1click:connect(function(player) dont work it cant detect Who clicked it

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