Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:26 AM |
event = game.ReplicatedStorage.CreateLeaderboard --Setup a variable leading to a remotevent in replicatedstorage (LEADERBOARD PART WORKS) event2 = game.ReplicatedStorage.ChangeStats --Setup a variable leading to a remotevent in replicatedstorage (THIS IS THE EVENT NOT WORKING)
event.OnServerEvent:connect(function() --Set it up for i,v in pairs(game.Players:GetPlayers()) do if not v:FindFirstChild("leaderstats") then local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = v local money = Instance.new("IntValue") money.Name = "Money" money.Value = 0 money.Parent = leaderstats end end end)
game.Players.PlayerAdded:connect(function() -- Player added event:FireServer() -- Fire the event end) event2.OnServerEvent:connect(function(plrName, statName, statValue) -- Boing. Lets set up arguments. if game.Players:FindFirstChild(plrName) then local player = game.Players:FindFirstChild(plrName) if player:FindFirstChild("leaderstats") then local leaderstats = player:FindFirstChild("leaderstats") if leaderstats:FindFirstChild(statName) then local stat = leaderstats:FindFirstChild(statName) stat.Value = statValue end end end
end)
event2:FireServer("Robin5D","Money",500)
This dosnt work, and dosnt set my money to 500 on the leaderboard. Any help?
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:27 AM |
Note I am new to fe scripting, sorry if the good fe coders freak out.
|
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 03:28 AM |
Your firing the event to the server inside a server script...........
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:34 AM |
lol thats for debug purposes only
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:35 AM |
been trying to execute it in console while testing, wont work
|
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 03:41 AM |
Go test>Start server and you will find magic in the output.
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:50 AM |
Magic output alert.
Cant be fired from the server.
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:58 AM |
Still cant get this working! Help.
LOCAL SCRIPT: event = game.ReplicatedStorage.ChangeStats
game.Players.PlayerAdded:connect(function(player) -- Player added event:FireServer(player) -- Fire the event end)
MAIN SCRIPT:
event = game.ReplicatedStorage.CreateLeaderboard event2 = game.ReplicatedStorage.ChangeStats event.OnServerEvent:connect(function(player) --Set it up
if not player:FindFirstChild("leaderstats") then local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("IntValue") money.Name = "Money" money.Value = 0 money.Parent = leaderstats
end end)
Cant get the leaderboard to show up
|
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
| |
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
| |
|
|
| 26 Jul 2016 04:14 AM |
| Is replicatedstorage even accessible through server? That's the client, right? |
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 04:18 AM |
not sure server output aint saying anythin
still scripting every dai |
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 04:21 AM |
UGH I PUT IT IN WORKSPACE AND CHANGED THE LOCALSCRIPT STILL NOT WORKING
still scripting every dai |
|
|
| Report Abuse |
|
|
| |
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 26 Jul 2016 06:20 AM |
You're not firing the correct event.
You're firing "event" in the localscript (some event named ChangeStats)
Then waiting for "event" in the server script, which isn't ChangeStats, but the leaderboard event, which never gets fired.
Make your variable names uniform throughout your scripts |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 26 Jul 2016 06:23 AM |
| Also, why are you having the playeradded event connect in the client? As more players join, there will be more clients firing the same line of code to the server, duplicating whatever actions the server does several times. |
|
|
| Report Abuse |
|
|
Real_Edgy
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 1212 |
|
|
| 26 Jul 2016 08:07 AM |
i'm pretty sure PlayerAdded is invisible to the client, no? or at least I thought it was?
I thought you had to use .ChildAdded()... |
|
|
| Report Abuse |
|
|
Real_Edgy
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 1212 |
|
|
| 26 Jul 2016 08:07 AM |
| wait nevermind it does now according to the wiki |
|
|
| Report Abuse |
|
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 26 Jul 2016 03:03 PM |
@wool that was fixed already
still scripting every dai |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 07:53 PM |
I have the solution to your problem, I decided to redesign your scripting because it was a bit 'Messy', No offense. Here is the coding:
--Create a Server Script in ServerScriptService --Optional Name: FilterEnableHandler (Public Script/Server Script/Not Local Script)
--Create a Local Script in PlayerGui --Optional Name: FireEvents (Local Script)
--Create two Remote Events in ReplicatedStorage Remote Event 1: CreateLeaderboard (Remote Event) Remote Event 2: ChangeStats (Remote Event)
--FilterEnableHandler Code: local CreateLeaderboardEvent = game:GetService('ReplicatedStorage'):WaitForChild('CreateLeaderboard') local ChangeStatsEvent = game:GetService('ReplicatedStorage'):WaitForChild('ChangeStats')
CreateLeaderboardEvent.OnServerEvent:connect(function(player) CreateLeaderboardEvent:FireAllClients(player) end)
ChangeStatsEvent.OnServerEvent:connect(function(player, Playername, StatName, StatValue) ChangeStatsEvent:FireAllClients(player, Playername, StatName, StatValue) end)
--FilterEnableHandler Code: local CreateLeaderboardEvent = game:GetService('ReplicatedStorage'):WaitForChild('CreateLeaderboard') local ChangeStatsEvent = game:GetService('ReplicatedStorage'):WaitForChild('ChangeStats')
CreateLeaderboardEvent.OnServerEvent:connect(function(player) CreateLeaderboardEvent:FireAllClients(player) end)
ChangeStatsEvent.OnServerEvent:connect(function(player, Playername, StatName, StatValue) ChangeStatsEvent:FireAllClients(player, Playername, StatName, StatValue) end)
--FireEvents Code: function LoadValues() local Playername = "Robin5D" local StatName = "Money" local StatValue = 500 ChangeStatsEvent:FireServer(Playername, StatName, StatValue) end
CreateLeaderboardEvent = game.ReplicatedStorage.CreateLeaderboard ChangeStatsEvent = game.ReplicatedStorage.ChangeStats
CreateLeaderboardEvent:FireServer()
function onCreateLeaderboardEvent(Player) for i,v in pairs(game.Players:GetPlayers()) do if not v:FindFirstChild("leaderstats") then local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = v local money = Instance.new("NumberValue") money.Name = "Money" money.Value = 0 money.Parent = leaderstats wait() LoadValues() end end end
function onChangeStatsEvent(LocalPlayer, Playername, StatName, StatValue) local Player = game.Players:FindFirstChild(Playername) if Player ~= nil then if Player:WaitForChild("leaderstats") ~= nil then if Player:WaitForChild("leaderstats"):WaitForChild(StatName) ~= nil then local stat = Player:WaitForChild("leaderstats"):WaitForChild(StatName) stat.Value = StatValue print("Fixed By: SYKOxXVenomXx, Your welcome.") end end end end
CreateLeaderboardEvent.OnClientEvent:connect(onCreateLeaderboardEvent) ChangeStatsEvent.OnClientEvent:connect(onChangeStatsEvent)
Feel free to add me, I am willing to help you out anytime you run into a Filtering Enabled Script Error.
~ Sincerely, SYKOxXVenomXx |
|
|
| Report Abuse |
|
|
| |
|