Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

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 yasquerda 32 — 3y
0
Then try changing it into a server script and keeping the PlayerAdded event? Omq_ItzJasmin 666 — 3y
0
as a server script it goes back to doing nothing yasquerda 32 — 3y
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 Omq_ItzJasmin 666 — 3y
Ad

Answer this question