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

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

Asked by 3 years ago
Edited 3 years ago

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

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. Creeper4203 0 — 3y

2 answers

Log in to vote
0
Answered by
cancle5 120
3 years ago

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

0
Don't use a remote event like that since it's very easy for a exploiter to get inf cash. cancle5 120 — 3y
0
Yes ik but how to make sellinng moneyislands1 51 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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

Answer this question