Yes, I’m using server script
(30 ).
Yes, I’m using server script
(30 ).
EDITED
You only need the player.PlayerAdded event, because even if the character is removed, the instances under the player will remain.
local Module = require(script.Parent:WaitForChild("ServerAdmin"):WaitForChild("ModuleScript"))
game.Players.PlayerAdded:Connect(function(player)
local Warning = Instance.new("IntValue")
Warning.Name = "Warnings"
Warning.Value = Module.LoadWarnings(player)
Warning.Parent = player
end)
game.Players.PlayerRemoving:Connect(function(player)
Module.SaveWarnings(player)
end)
I added the character added because It didn’t work like you said
Also, Im not sure if this is the case but whenever I have a characterAdded event it only fires once the character has died and respawned, for me anyway it never works when a player loads in for the first time.
So I would recommend using @JollyGameCrazy method.
Well that doesn’t do any good.
I have also a module script
Do you think its breaking the script?
All the other scripts running correctly!
When I call the function it’s just getting values from DataStore
If you are testing in studio the player might load before the PlayerAdded event is firing, you can test this by adding a print("player joined")
inside of the player added block aswell as adding a print check inside of the character added block.
What is showing in the output?
new script
local Module = require(script.Parent:WaitForChild("ServerAdmin"):WaitForChild("ModuleScript"))
game.Players.PlayerAdded:Connect(function(player)
print("player joined")
local Warning = Instance.new("IntValue")
Warning.Name = "Warnings"
--Warning.Value = Module.LoadWarnings(player)
Warning.Parent = player
print("Parented")
end)
game.Players.PlayerRemoving:Connect(function(player)
Module.SaveWarnings(player)
end)
nothing in output
instead of game.Players
, use game:GetService("Players")
It’s likely that you are infinitely waiting for ServerAdmin or ModuleScript
There would be an infinite yield warning, if that was the case.
I don’t think, if you stop the test immediately, most errors will not come out.
nothing in output
Thanks for everyone who tried to help
Put a print() below the require(), if the wait is really infinite, it won’t print.
Ya It doesn’t print anything in the output
You should move the module to ServerStorage because as the name says, it is for scripts only.
I moved the module scripts
And I found the problem
without requiring the module:
with requiring:
It is because of the infinite wait, if you want to confirm it, inside the require(), but in the end, put a comma and 1, the value will have nil.
local Module = require(script.Parent:WaitForChild("ServerAdmin"):WaitForChild("ModuleScript"),1)
Leave the folder in ServerStorage.
local ServerStorage = game:GetService("ServerStorage")
local Module = require(ServerStorage:WaitForChild("ServerAdmin"):WaitForChild("ModuleScript"))
There are better values: FastValue a replacement for Value Instances that is better than Remotes and Bindables