I have a localscript trying to fire a serverscript. The LS is placed in StarterGUI, the SS is placed in ServerStorage, the RemoteEvent in ReplicatedStorage.
Localscript
01 | --Waits for player then fires ServerScript-- |
02 |
03 | game.Players.PlayerAdded:Connect( function (player) |
04 | player.CharacterAdded:Connect( function (character) |
05 | local hrp = character:WaitForChild( "HumanoidRootPart" , 3 ) |
06 |
07 | if hrp then |
08 | game.ReplicatedStorage.RemoteEvents.LBLoad:FireServer() |
09 | else |
10 |
11 | end |
12 | end ) |
13 | end ) |
Serverscript
01 | --Loads Leaderboard after finding local player in a localscript-- |
02 | game.ReplicatedStorage.RemoteEvents.LBLoad.OnServerEvent:Connect( function () |
03 |
04 |
05 | game.Players.PlayerAdded:connect( function (p) |
06 | local stats = Instance.new( "IntValue" ) |
07 | stats.Name = "leaderstats" |
08 | stats.Parent = p |
09 |
10 | local money = Instance.new( "IntValue" ) |
11 | money.Name = "Money" |
12 | money.Value = 0 |
13 | money.Parent = stats |
14 | local bounty = Instance.new( "IntValue" ) |
15 | bounty.Name = "Bounty" |
16 | bounty.Value = 0 |
17 | bounty.Parent = stats |
18 | end ) |
19 |
20 | end ) |
I've also tried V
01 | --Loads Leaderboard after finding local player in a localscript-- |
02 | game.ReplicatedStorage.RemoteEvents.LBLoad.OnServerEvent:Connect( function () |
03 |
04 |
05 |
06 | local stats = Instance.new( "IntValue" ) |
07 | stats.Name = "leaderstats" |
08 | stats.Parent = game.Players.PlayerAdded |
09 |
10 | local money = Instance.new( "IntValue" ) |
11 | money.Name = "Money" |
12 | money.Value = 0 |
13 | money.Parent = stats |
14 |
15 | local bounty = Instance.new( "IntValue" ) |
It isn't creating the leaderboard which means it is not firing the remotevent because "leaderstats in not a valid member of Player"
You don't do playeradded events or any characteradded events those should be only done in the server
Also I don't see a point on why you are using a local script for a leaderboard everything here can and should be done on a server
it should be more like
01 | game.Players.PlayerAdded:Connect( function (player) |
02 |
03 | local stats = Instance.new( "IntValue" ) |
04 | stats.Name = "leaderstats" |
05 | stats.Parent = game.Players.PlayerAdded |
06 |
07 | local money = Instance.new( "IntValue" ) |
08 | money.Name = "Money" |
09 | money.Value = 0 |
10 | money.Parent = stats |
11 |
12 | local bounty = Instance.new( "IntValue" ) |
13 | bounty.Name = "Bounty" |
14 | bounty.Value = 0 |
15 | bounty.Parent = stats |
16 |
17 | end ) |