#DM me if you can help please...

1 messages · Page 1 of 1 (latest)

green spoke
#

send script in this format preferably:

-- ur code
prime condor
#

-- Place this script in ServerScriptService or a LocalScript under StarterPlayerScripts

local SellArea = workspace:WaitForChild("SellArea") -- This is your circle part
local OreName = "Ore" -- The name of the ore that players can sell
local CurrencyName = "Coins" -- The currency to give to players when selling ores
local OreValue = 10 -- How many coins for each ore sold

-- Function to handle player entering the sell area
local function onPlayerTouch(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player and player.Character then
local char = player.Character
local ore = char:FindFirstChild(OreName)

    if ore then
        -- Make sure the player has the ore to sell
        local coins = player:FindFirstChild(CurrencyName)
        
        if not coins then
            coins = Instance.new("IntValue")
            coins.Name = CurrencyName
            coins.Parent = player
            coins.Value = 0
        end
        
        -- Reward the player with coins for selling the ore
        coins.Value = coins.Value + OreValue
        ore:Destroy()  -- Remove the ore after selling
        
        -- Optional: Notify the player they have sold the ore
        player:SendMessage("You have sold your ore for " .. OreValue .. " " .. CurrencyName .. "!")
    end
end

end

-- Detect when a player touches the sell area
SellArea.Touched:Connect(onPlayerTouch)

green spoke
#

like this

prime condor
#
```   -- Place this script in ServerScriptService or a LocalScript under StarterPlayerScripts

local SellArea = workspace:WaitForChild("SellArea")  -- This is your circle part
local OreName = "Ore"  -- The name of the ore that players can sell
local CurrencyName = "Coins"  -- The currency to give to players when selling ores
local OreValue = 10  -- How many coins for each ore sold

-- Function to handle player entering the sell area
local function onPlayerTouch(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if player and player.Character then
        local char = player.Character
        local ore = char:FindFirstChild(OreName)

        if ore then
            -- Make sure the player has the ore to sell
            local coins = player:FindFirstChild(CurrencyName)

            if not coins then
                coins = Instance.new("IntValue")
                coins.Name = CurrencyName
                coins.Parent = player
                coins.Value = 0
            end

            -- Reward the player with coins for selling the ore
            coins.Value = coins.Value + OreValue
            ore:Destroy()  -- Remove the ore after selling

            -- Optional: Notify the player they have sold the ore
            player:SendMessage("You have sold your ore for " .. OreValue .. " " .. CurrencyName .. "!")
        end
    end
end

-- Detect when a player touches the sell area
SellArea.Touched:Connect(onPlayerTouch)```
green spoke
#

in lower case

#

and put ur code in the middle

prime condor
#

uh how do i change it to lower case

#

just type it out?

green spoke
#

bro why can't you type it in lowercase lol

prime condor
#

i copied and pasted it from chat gpt

twilit lagoonBOT
#

studio** You are now Level 1! **studio

green spoke
#

dang

#

yeah just type it out

prime condor
#

is that a problem

#

ok

#
   -- place this script in serverscriptservice or a localScript under starterplayerscripts

local sellarea = workspace:waitforchild("sellarea")  -- this is your circle part
local oreName = "ore"  -- the name of the ore that players can sell
local currencyName = "coins"  -- the currency to give to players when selling ores
local oreValue = 10  -- how many coins for each ore sold

-- function to handle player entering the sell area
local function onplayertouch(hit)
    local player = game:GetService("players"):getplayerfromcharacter(hit.parent)
    if player and player.character then
        local char = player.character
        local ore = char:findfirstchild(oreName)

        if ore then
            -- make sure the player has the ore to sell
            local coins = player:findfirstchild(currencyName)

            if not coins then
                coins = instance.new("intValue")
                coins.Name = currencyName
                coins.Parent = player
                coins.Value = 0
            end

            -- reward the player with coins for selling the ore
            coins.Value = coins.Value + oreValue
            ore:destroy()  -- remove the ore after selling

            -- optional: notify the player they have sold the ore
            player:sendmessage("You have sold your ore for " .. oreValue .. " " .. CurrencyName .. "!")
        end
    end
end

-- detect when a player touches the sell area
sellArea.touched:connect(onplayertouch)```
#

good?

green spoke
#

brotha

#

you still said LUA

#

in the beginning

prime condor
#

oops

#

changed it

green spoke
#

ok lemme just do it for you

#
 -- place this script in serverscriptservice or a localScript under starterplayerscripts

local sellarea = workspace:waitforchild("sellarea")  -- this is your circle part
local oreName = "ore"  -- the name of the ore that players can sell
local currencyName = "coins"  -- the currency to give to players when selling ores
local oreValue = 10  -- how many coins for each ore sold

-- function to handle player entering the sell area
local function onplayertouch(hit)
    local player = game:GetService("players"):getplayerfromcharacter(hit.parent)
    if player and player.character then
        local char = player.character
        local ore = char:findfirstchild(oreName)

        if ore then
            -- make sure the player has the ore to sell
            local coins = player:findfirstchild(currencyName)

            if not coins then
                coins = instance.new("intValue")
                coins.Name = currencyName
                coins.Parent = player
                coins.Value = 0
            end

            -- reward the player with coins for selling the ore
            coins.Value = coins.Value + oreValue
            ore:destroy()  -- remove the ore after selling

            -- optional: notify the player they have sold the ore
            player:sendmessage("You have sold your ore for " .. oreValue .. " " .. CurrencyName .. "!")
        end
    end
end

-- detect when a player touches the sell area
sellArea.touched:connect(onplayertouch)
#

there you go

prime condor
#

DANG you did that fast

#

so what now

green spoke
#

ok

#

so

#

what you do you want to do

prime condor
#

i want to make it so when the player steps into a circle it sells there ores

#

this circle

green spoke
#

ok lemme get rid of the comments real quick because they're very redundant

prime condor
#

k

green spoke
#
local sellarea = workspace:waitforchild("sellarea") 
local oreName = "ore"  
local currencyName = "coins" 
local oreValue = 10
local function onplayertouch(hit)
    local player = game:GetService("players"):getplayerfromcharacter(hit.parent)
    if player and player.character then
        local char = player.character
        local ore = char:findfirstchild(oreName)
        if ore then
            local coins = player:findfirstchild(currencyName)

            if not coins then
                coins = instance.new("intValue")
                coins.Name = currencyName
                coins.Parent = player
                coins.Value = 0
            end
            coins.Value = coins.Value + oreValue
            ore:destroy() 
            player:sendmessage("You have sold your ore for " .. oreValue .. " " .. CurrencyName .. "!")
        end
    end
end
sellArea.touched:connect(onplayertouch)
#

less yap

#

anyway

prime condor
#

i copy that into the script

green spoke
#

I just got rid of the comments didn't do anything yet

prime condor
#

o

green spoke
#

btw are you doing this as a leaderstats thing

#

yk those stats on the right of ur screen

#

are you trying to change those

prime condor
#

no i alr changed those i think

green spoke
#

yes

#

ok so your script constantly resets them to 0 you should be adding those when the player joins for the first time not when you touch the part

prime condor
#

so what do i change im kinda dum with scripting

green spoke
#

so you see the part where you create the stat do that when you join for the first time using a playeradded event

#

lemme send it

#
game.Players.PlayerAdded:Connect(function()
local coins = instance.new("intValue")
                coins.Name = currencyName
                coins.Parent = player
end()
#

imma open up studio to speedup this rq

prime condor
#

ok

green spoke
#
local sellAreaPart = workspace:WaitForChild("sellarea") 
game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Value = 0
    coins.Parent = leaderstats
end)

sellAreaPart.Touched:Connect(function(HitPart)
    local partParent = HitPart.Parent
    local player = partParent:GetPlayerFromCharacter(partParent)
    local leaderstats = player and player:FindFirstChild("leaderstats")
    local coinsStat = leaderstats and leaderstats:FindFirstChild("Coins")
    if coinsStat then
        coinsStat.Value += 10
    end
end)
wild hawk
#

What's not working

green spoke
# wild hawk What's not working

his leaderboard stat wasn't going up because was setting it to 0 everytime he touched a part and creating it there instead of when the playerjoins

wild hawk
#

Oh

green spoke
#

it should work now

prime condor
#

so i copy and paste the code into a script

twilit lagoonBOT
#

studio** You are now Level 2! **studio

green spoke
#

yeah but I bet he could've done it if he looked at docs instead of chatgpt ngl

green spoke
wild hawk
#

Vibe coder?

glad silo
wild hawk
#

There are so many these days

glad silo
#

what do you mean vibe coder

prime condor
#

how do i put the thing in the circle tho

green spoke
wild hawk
#

A person who write all their code by using chatgpt

twilit lagoonBOT
#

studio** You are now Level 9! **studio

wild hawk
#

Or AI

#

Any AI

prime condor
#

wait what did the code that you send do

#

did it make the seller?

green spoke
prime condor
#

for it to work all you have to do is enter this right

#

or do i need to save it or sum

green spoke
#

try it

#

should work

#

also why's your theme white 😭 my eyes

wild hawk
#

My eyes also hurt

#

Dark theme forever

prime condor
#

lol

prime condor
green spoke
#

sure

prime condor
#

gen 2?

green spoke
#

alr

wild hawk
#

Anyways it might be worth the time to learn how to script especially if you want to actually make something good because if it gets too complex then chatgpt won't make it right

#

The dev king on YouTube has great tutorials that I used to follow in 2020 (the videos were made in 2019 tho)

#

Dunno if he has an updated one