Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this script not make a Folder and value in a real game?

Asked by 5 years ago

So when a player joins it should create a new folder and values inside that folder. But when i create a new server it doesn't do that why? Server Script

local removeEvent = game.ReplicatedStorage.PlayerTo

game.Players.PlayerAdded:Connect(function(player)
    removeEvent:FireClient(player)
end)

** Local Script **

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("PlayerTo")

event.OnClientEvent:Connect(function()
    local NewFolder = Instance.new("Folder")
    NewFolder.Parent = game.Workspace.Stat
    NewFolder.Name = game.Players.LocalPlayer.Name
    local PointValue = Instance.new("NumberValue")
    PointValue.Value = 0
    PointValue.Name = "Points"
    PointValue.Parent = NewFolder
    local AssistValue = Instance.new("NumberValue")
    AssistValue.Value = 0
    AssistValue.Name = "Assists"
    AssistValue.Parent = NewFolder
end)
1
Put all the folder making stuff in the server script and then just remove the local. Adding a folder to the player cannot be done and shown to the whole server if you are using a local script I think. happytimeroblox101 36 — 5y
1
This also means you don't need a event happytimeroblox101 36 — 5y
0
tysm WillBe_Stoped 71 — 5y
0
please accept my answer :) happytimeroblox101 36 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

Put all the folder making stuff in the server script and then just remove the local. Adding a folder to the player cannot be done and shown to the whole server if you are using a local script I think. This also means you don't need a event

-- server side


game.Players.PlayerAdded:Connect(function(player) local NewFolder = Instance.new("Folder") NewFolder.Parent = game.Workspace.Stat NewFolder.Name = player.Name local PointValue = Instance.new("NumberValue") PointValue.Value = 0 PointValue.Name = "Points" PointValue.Parent = NewFolder local AssistValue = Instance.new("NumberValue") AssistValue.Value = 0 AssistValue.Name = "Assists" AssistValue.Parent = NewFolder end)

If I were you I would put the folder in the player in players them self and not workspace, but that's your choice

Ad

Answer this question