Hello I need help with my game so I have a Tix/Coin you can call it I want it to do this so when a player touches the Tix/Coin whatever you wanna call it it should disappear and add 1 point in the leaderboard i dont want a gui leaderboard i want a regular leaderboard and if a player rejoins i dont want them to keep grinding in one tix/coin so no respawn Thank you!
#A Tix/Coin Scripting Problem
161 messages · Page 1 of 1 (latest)
Can you script well?
💀I don't think that helps much here
Yes
what is it then 😦
Gimme a sec I'm helping someone else
alr
i am gonna be playing roblox for then
when you are done mention me okay
??
Alr
show us your code
They don't have any
i dont have any
code to make a part disapear on touch and add plus one to a stat?
no so i want to do is this when a player touches a part they get 1 point right. Then after when they get the point the part disappears and if the player rejoins then they can't keep standing there and keep grinding the same coin
@modern harness
Here's the basic idea:
-
Use some sort of mass scripting (collection service, loops, modules, etc.) to detect a touch
-
If it's a player, update their leader stats value
-
Turn off can touch, can collide, etc.
-
Put that coin in a table with a bool or something that shows that it's been touched by the player.
-
When a player joins, get the data store and loop through the table setting the touch detections back on
I dont know anything of about this

you will need to learn this is basic stuff
potato gave you all the parts
you need to learn datastores to store player data
api
its not really basic but it's essential for a cool game ¯_(ツ)_/¯
is there for datastore
true but can anyone script it for me
Probably but you have to check #💵︱hiring or #👷︱for-hire
Most people in scripting help won't make scripts for you
There's people that work for free
There's a role but I'm not sure how it works
I have it bc idk how to get rid of it 😭
But there's people that actually will script for free
okay so i go into the hiring
I recommend watching tutorials or something tho
you could learn this stuff in a weak my dude
And follow my outline
** You are now Level 1! **
save your money, develop your skills
Yeah it's not an easy concept but easy to learn
If that makes sense
There's tons of resources
Unpopular opinion, ai is really useful if you give it detailed prompts
everytime i do
the parts go somwhere random
but wait i do have code
i have code wait wait
Yeah you need a bit of knowledge to fix the code tho
AI is inconsistent af
Lemme try something
you may need to actually learn how coding in general works
this is the code that i have so far
that might help you faster
local pointsDataStore = DataStoreService:GetDataStore("PlayerPoints")
game.Players.PlayerAdded:Connect(function(player)
local playerId = player.UserId
local playerKey = "Points_" .. playerId
-- Load player's points from datastore
local success, points = pcall(function()
return pointsDataStore:GetAsync(playerKey)
end)
if success then
-- Create leaderstats if not exists
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create Points value
local pointsValue = Instance.new("IntValue")
pointsValue.Name = "Points"
pointsValue.Value = points or 0
pointsValue.Parent = leaderstats
-- Save points when player leaves
player:Connect(function()
local success, error = pcall(function()
pointsDataStore:SetAsync(playerKey, pointsValue.Value)
end)
if not success then
warn("Failed to save data: " .. error)
end
end)
else
warn("Failed to load data for player " .. player.Name)
end
end)```
ok what happens when you run it
this was in ServerScriptService
why? did you make it?
well the problem is obvious
image player a was touching it after he got the point the part disappears but after it disappears other people can still see it
** You are now Level 4! **
are you starting the server when you join the game?
does the part get created when the server starts?
no its already spawned there
yeah i guess so
if i am right
i am not that too good at
this stuf
thats alright, did you place it there?
yeah but you want it to not be there when you rejoin
so you want to rejoin without restarting the server?
or you want the server to save that the part is gone
yeah
i want the server to know that one player touched the part
so he can't touch it again
only the other players who have not found it
let me send you a short clip
when chatting with ai might might be better to talk seperately about how you choose to plan certain things before going to another chat about developing, for future reference.
when I did a bachelors Degree in software we were forced to do a whole paper (2 month) on just planning how a user is going to interact.
** You are now Level 2! **
Ah
you see
so when the part has been touched the part is destroyed forever?
So you want the Points to save and the Part to be removed?
yes
so if the player a touches the part then the games saves it after he rejoins but then he can't see the part but the other players can
I will appericate it
Would you mind adding me to the Baseplate your working on?
1q_87
local DataStoreService = game:GetService("DataStoreService")
local pointsDataStore = DataStoreService:GetDataStore("PlayerPoints")
local partTouchDataStore = DataStoreService:GetDataStore("PartTouchData")
local part = game.Workspace:WaitForChild("YourPartName") -- Replace "YourPartName" with the actual part's name
-- Function to handle player data
local function handlePlayerData(player)
local playerId = player.UserId
local playerKey = "Points_" .. playerId
-- Load player's points from datastore
local success, points = pcall(function()
return pointsDataStore:GetAsync(playerKey)
end)
if success then
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats then
leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end
local pointsValue = leaderstats:FindFirstChild("Points")
if not pointsValue then
pointsValue = Instance.new("IntValue")
pointsValue.Name = "Points"
pointsValue.Value = points or 0
pointsValue.Parent = leaderstats
else
pointsValue.Value = points or 0
end
player.AncestryChanged:Connect(function(_, parent)
if not parent then
local success, error = pcall(function()
pointsDataStore:SetAsync(playerKey, pointsValue.Value)
end)
if not success then
warn("Failed to save data: " .. error)
end
end
end)
else
warn("Failed to load data for player " .. player.Name)
end
end
-- Check if part has been touched before
local function checkPartTouchedStatus()
local success, hasBeenTouched = pcall(function()
return partTouchDataStore:GetAsync("PartTouchedStatus")
end)
if success then
if hasBeenTouched then
print("The part has been touched before. Destroying the part.")
part:Destroy()
else
print("The part has not been touched before.")
end
else
warn("Failed to check part touched status.")
end
end
-- Save part touched status
local function savePartTouchedStatus()
local success, error = pcall(function()
partTouchDataStore:SetAsync("PartTouchedStatus", true)
end)
if not success then
warn("Failed to save part touched status: " .. error)
end
end
-- Handle part touched event
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
savePartTouchedStatus()
-- You can handle additional logic here, e.g., award points
print(player.Name .. " touched the part.")
end
end)
-- Connect to player added event
game.Players.PlayerAdded:Connect(handlePlayerData)
-- Check part touched status on server start
checkPartTouchedStatus()
try that
or this ```-- File: ServerScriptService/PartTouchTracker.lua
local DataStoreService = game:GetService("DataStoreService")
local pointsDataStore = DataStoreService:GetDataStore("PlayerPoints")
local partTouchDataStore = DataStoreService:GetDataStore("PartTouchData")
local part = game.Workspace:WaitForChild("YourPartName") -- Replace "YourPartName" with the actual part's name
-- Function to handle player data
local function handlePlayerData(player)
local playerId = player.UserId
local playerKey = "Points_" .. playerId
-- Load player's points from datastore
local success, points = pcall(function()
return pointsDataStore:GetAsync(playerKey)
end)
if success then
-- Create leaderstats if not exists
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create Points value
local pointsValue = Instance.new("IntValue")
pointsValue.Name = "Points"
pointsValue.Value = points or 0
pointsValue.Parent = leaderstats
-- Save points when player leaves
player:Connect(function()
local success, error = pcall(function()
pointsDataStore:SetAsync(playerKey, pointsValue.Value)
end)
if not success then
warn("Failed to save data: " .. error)
end)
end)
else
warn("Failed to load data for player " .. player.Name)
end
end
-- Check if part has been touched before
local function checkPartTouchedStatus()
local success, hasBeenTouched = pcall(function()
return partTouchDataStore:GetAsync("PartTouchedStatus")
end)
if success and hasBeenTouched then
print("The part has been touched before. Destroying the part.")
part:Destroy()
else
print("The part has not been touched before.")
end
end
-- Save part touched status
local function savePartTouchedStatus()
local success, error = pcall(function()
partTouchDataStore:SetAsync("PartTouchedStatus", true)
end)
if not success then
warn("Failed to save part touched status: " .. error)
end
end
-- Handle part touched event
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
savePartTouchedStatus()
-- You can handle additional logic here, e.g., award points
print(player.Name .. " touched the part.")
end
end)
-- Connect to player added event
game.Players.PlayerAdded:Connect(handlePlayerData)
-- Check part touched status on server start
checkPartTouchedStatus()```
yes
does it work though?
thats good man im really happy
yeah for sure
i sent you a friend request thank you so much
Everyone thanks for you help
Do i remove the post now
3 little dots at the top, if you hover over it it says more
Thank you