Please considier putting the code on a block.
What do you want to achieve?
So i wanted to make something that sells my genetics and turns it into coins but its not working for some reason, it only works when the player starts of with a number of genetic and then it turns it to coins but when i click the tool that gives me genetics and try selling it to make it into coins it doesnt work.
Edit: Is a local?
Well since you cant change server values from a client then you need to use remote events, that would be a good option.
You should read this API reference and get more info about it.
no its not a local, but yeah i will look into it
is there any other advice you got for me or any way of helping me?
Check Bindable event instead then.
Im sorry, but i have no clue what that is.
The issue isn’t with networking as they’re using a Touched event which will presumably be done on the server.
I believe the issue will arise somewhere from your indexing. If your data is a leaderboard value, you’ll have to do “leaderstats” to reference the data folder, as seen in the following code:
local data = player:WaitForChild("leaderstats")
However, if it isn’t a leaderboard and is rather an internal datastore, the issue will be a logic issue, like the genetics value isn’t properly being updated
It is possible, although I would be more inclined to check if the player is within a radius in a localscript, and then fire an event to the server.
this is what i have
what should i change for that script to actually work?
local part = script.Parent part.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local data = player:WaitForChild("leaderstats") -- YOUR FOLDER local coins = data.Coins local genetics = data.Genetics if coins and genetics then -- Your code end end end)
I did this, put it inside the part, works perfectly.
Edit: Modify it so it works for you
ok im goign to try that right now ill let you know
where it says my code, i put
if Genetics.Value > 0 then
Coins.Value = Coins.Value + Genetics.Value *
Genetics.Value = 0
Put that there
its not working :c and i put that there,
their is also no errors
want me to send you a vid? of it
local part = script.Parent part.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local data = player:WaitForChild("data") local coins = data.Coins local genetics = data.Genetics if coins and genetics then if genetics.Value > 0 then data.Coins.Value = data.Coins.Value + data.Genetics.Value * 1 data.Genetics.Value = 0 else return end end end end)
Alternatively check for proximity on the server … I’ve found it more convenient.
With regards to your latest post, sharing an entire code block is likely not going to teach the OP anything. A few comments would help.