I want to make this script change a value for a datastore and change the color of the part. I have been posting a lot of questions but I think this one is the last for now.
whenever I try to run the script nothing happens. the value doesn't change and neither does the color.
here is the script (local but I could change it to nonlocal I think.)
Gravel = workspace.Things.gravel
Button = script.Parent
function color(player)
local ColorNum = player.DataFolder.GravelColor.Value
Gravel.BrickColor = BrickColor.new("Cyan")
ColorNum = 3
end
game.Players.PlayerAdded:Connect(function(player)
while true do
color(player)
wait(0.2)
end
end)
Any idea on how to fix this?

4 comments
thank you but i am still having the issue that I had before anything was changed in my code. also I meant to replace the while true do with when button pressed. the value still isn't changing in the DataFolder
Then try changing it into a server script and keeping the PlayerAdded event?
as a server script it goes back to doing nothing
Then it must be something else.......check if anything is missing and if this isn't your entire script try posting the full version