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

No error comes up, it's inside a part in workspace?

local part = script.Parent
game.Players.PlayerAdded:Connect(function(player)
if player.leaderstats.Credits.Value >= 500 then
wait()
	print ("you reached")
	part.CanCollide = false
	part.Transparency = 1
end

end)

11 comments

0

what

0

does it print in the output

0

it doesnt not

0

the only thing that might be stopping the if statement is that the player has less than 500 stats

0

When you join the game, do you have 500 credits? [without changing nothing after the load]

0

i set it equal to 0 and it still didnt print

0

no i start with 0

0

Problem found, you need to run this on a loop to work

0

a while loop? and the original script or another one

0

place lines 3 - 7 on a while loop, and remove the PlayerAdded event, it will work

0

Player isnt defined then

2 answers

local part = script.Parent
game.Players.PlayerAdded:Connect(function(player)
if player.leaderstats.Credits.Value <= 500 then
wait()
    print ("you reached")
    part.CanCollide = false
    part.Transparency = 1
end

4 comments

0

@1bitPro didnt work :/

0

:( sorry

0

hold on...

0

okay thank you for your time

There is some small minor issues that needs fixing: 1. If the leaders tats doesn't exist then the whole if statement won't work also. You need to provide and else or the script won't error.

while true do
wait()
local part = script.Parent
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new( "Folder",player)
stats.Name= "leaderstats"

 local Credits = Instance.new( "IntValue",stats)
Credits.Name = "Credits"
if player.leaderstats.Credits.Value >= 500 then
wait()
    print ("you reached")
    part.CanCollide = false
    part.Transparency = 1
else
print ( "Error")
end
end
end

7 comments

0

wouldn't that over write the leaderstats I already made?

0

No simply delete the leaderstats script that you made because the server doesnt know what leaderstat your talking about so make sure its in the same script

0

Also make sure to accept

0

my leaderstats got DataStore though

0

And make sure you use a while e server constantly checks to see if you have 500 credits

0

Then paste the datastore and delete the leaderstats

0

Copy the one that i made

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