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

How to make shared value for all players in one server?

Asked by 6 years ago

Hey there!

I am currently making a game where players have to collect wooden sticks to "feed" the fire pit. (But that's not the point of this question.) Anyways, every players sees the "ingame currency" (sticks) value differently.

Let's say I collect 3 sticks and I see number 3, meanwhile my friend sees only 2 which he collected.

Is there any way to create "shared" NumberValue/IntValue which will player see the same everytime ?

Thanks!

Regards, ItzBlazik.

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

There is a way!I can give you this!

NOTE:Im kinda unsure too,it might not be the actual one,but I try my best!I am noob at scripting lol

local Players = game.Players

local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'

Instance.new('IntValue', Template).Name = "Sticks"


Players.PlayerAdded:connect(function(Player)
    wait(1)
    local Stats = Template:Clone()
    Stats.Parent = Player
    local Deaths = Stats.Deaths
    Player.CharacterAdded:connect(function(Character)
        Deaths.Value = Deaths.Value + 1
        local Humanoid = Character:FindFirstChild "Humanoid"
        if Humanoid then
            Humanoid.Died:connect(function()
                for i, Child in pairs(Humanoid:GetChildren()) do
                    if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
                        local Killer = Child.Value
                        if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
                            local Kills = Killer.leaderstats.Kills
                            Kills.Value = Kills.Value + 1
                        end
                    end
                end
            end)
        end
    end)
end)

Customize that or edit it,ONLY IF IT WON'T WORK.

Good Luck!Can't wait to your game!

0
I am not quite sure this is it, there is a function in my game where you collect sticks from ground and it counts in specific value (which i put in replicatedstorage in hope it will fix it). What I want to do here is so it show the same number (value stored in replicated st.) for all players joined. ItzBlazik 9 — 6y
0
oh okay GruDru888 0 — 6y
Ad
Log in to vote
0
Answered by
Zunaxo -3
6 years ago

Let me help you out there real quick just put a Value into the Workspace and lets call it Sticks and let the gui check that Values value its that simple.

0
Umm, I've already tried that. It didn't get fixed that way at all. ItzBlazik 9 — 6y
Log in to vote
0
Answered by 6 years ago

I finally fixed it! All I needed to do is put those values in workspace and disable filteringenabled

Answer this question