Instance Not Being Created

Yes, I’m using server script

(30 ).

1 Like

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.

2 Likes

Well that doesn’t do any good.

1 Like

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.

1 Like

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")

1 Like

It’s likely that you are infinitely waiting for ServerAdmin or ModuleScript

2 Likes

There would be an infinite yield warning, if that was the case.

2 Likes

I don’t think, if you stop the test immediately, most errors will not come out.

1 Like

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.

1 Like

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.

1 Like

I moved the module scripts
And I found the problem
without requiring the module:
Screenshot_24
with requiring:
Screenshot_23

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"))
1 Like

There are better values: FastValue a replacement for Value Instances that is better than Remotes and Bindables