#DM me if you can help please...
1 messages · Page 1 of 1 (latest)
-- 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)
like this
``` -- 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)```
bro why can't you type it in lowercase lol
i copied and pasted it from chat gpt
** You are now Level 1! **
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?
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
i want to make it so when the player steps into a circle it sells there ores
this circle
ok lemme get rid of the comments real quick because they're very redundant
k
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
i copy that into the script
I just got rid of the comments didn't do anything yet
o
btw are you doing this as a leaderstats thing
yk those stats on the right of ur screen
are you trying to change those
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
so what do i change im kinda dum with scripting
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
ok
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)
btw you can easily find all this on docs
https://create.roblox.com/docs/players/leaderboards
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
Oh
it should work now
so i copy and paste the code into a script
** You are now Level 2! **
yeah but I bet he could've done it if he looked at docs instead of chatgpt ngl
yes
Vibe coder?
what
There are so many these days
what do you mean vibe coder
how do i put the thing in the circle tho
what thing
A person who write all their code by using chatgpt
** You are now Level 9! **
makes the coins go up by 10 everytime you touch the circle
for it to work all you have to do is enter this right
or do i need to save it or sum
lol
do you think we can call and ill stream ?
sure
gen 2?
alr
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