You can write your topic however you want, but you need to answer these questions:
-
I want to get the value from an IntValue
-
I just can’t get the IntValue
So basically, I made it so each player has an IntValue created in a remotestorage folder called “Values”. But I can’t find a way to access it.
local player = game.Players.LocalPlayer
print(player)
local rapvalue = game.ReplicatedStorage.Values:WaitForChild(player).Value
print(rapvalue)
if rapvalue >= 10 then
game.Workspace.Rap.CanCollide = false
end
Does it show any errors in the output?
It shows Infinite yield possible on ‘ReplicatedStorage.Values:WaitForChild(“Instance”)’
local player = game.Players.LocalPlayer
print(player)
local rapvalue = game.ReplicatedStorage.Values:WaitForChild(player)
print(rapvalue)
if rapvalue.Value >= 10 then
game.Workspace.Rap.CanCollide = false
end
Tell me if this works
If you named the Values correctly, change it to
local rapvalue = game.ReplicatedStorage.Values:WaitForChild(player.Name).Value
It wil lwait for the Value with the name of the player, currently, you gave it an instance to wait for, WaitForChild
typically uses a string to refer to
Wait so is the script a local script or server script?
1 Like
The script is a local script inside StarterPlayerScripts
1 Like
Are the Values named by the name of the players? If so, try what I wrote in my post
1 Like
I tried what you wrote in your post, but it doesn’t print the correct value
Could you send a screenshot of the explorer showing the objects in replicated storage?
1 Like
What is it printing and what is it supposed to print? Perhaps try remove the .Value
and putting it in if the statement
if rapvalue.Value >= 10 then
2 Likes
That’s probably why then, you immediately got the value of the IntValue as soon as it was made, and by then, the value may’ve already changed. Try out what I posted
Your code should look like this
local player = game.Players.LocalPlayer
print(player)
local rapvalue = game.ReplicatedStorage.Values:WaitForChild(player.Name)
print(rapvalue.Value)
if rapvalue.Value >= 10 then
game.Workspace.Rap.CanCollide = false
end
This way it will get the latest value in the IntValue
2 Likes
Thx, what @EmbatTheHybrid just said should fix it then because it puts the value named as a player
1 Like
Thanks, I just put a wait(1) and it got the correct value. Many many many thanks to you both!
2 Likes
Anytime! If you have anymore issues don’t be afraid to make another post!
No Problem, have a nice day! 