Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why is this script not working to change both a color and number value?

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?

1 answer

HEYO, I remember you on the other comment and you said it was a local script, so I updated my script so it could fit. Remove the playeradded event and just use LocalPlayer

while true do
	color(game.Players.LocalPlayer)
	wait(.2)
end

SORRY IF I CONFUSED YOU ON THE OTHER QUESTION

4 comments

0

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

0

Then try changing it into a server script and keeping the PlayerAdded event?

0

as a server script it goes back to doing nothing

0

Then it must be something else.......check if anything is missing and if this isn't your entire script try posting the full version

This discussion is preserved as it was. New answers, comments, and votes are closed.