#Tycoon, Car dealership
66 messages · Page 1 of 1 (latest)
The 2 leaderstats issue
You have 2 leaderstats script, go disable one
I dont know how to find it
CTRL + Shift + Fin Explorer → Search for "leaderstats" → disable one of the 2 scripts
The cash away
99% of the time its because you remove your money from a LocalScript, it wont work since whatever you change in a local script will apply to the player eyes only, so the server wont know for money changes
How can i solve that ?
Use a remote event
almost pinged somebody
you can keep your robux
np
I think he means folders, in that case, delete the folder
no cause generally, leaderstats are autogenerated from scripts
** You are now Level 31! **
so if they are generated from script, its a good pratcite to not create 2 of them
ok
if you really wanna spend 500 robux, hire a scripter for this price to make your whole dealership system
right. I should maybe relearn studio
nah dont say that 👍
oh no I actually should I forgot instances inside players have to be replicated
Haven't spend any time on scripting in ages
no but like here im just talking about leaderstats haha
mostly all leaderstats are created in a script but not all instances
Still gets either replicated or created by a script
¯_(ツ)_/¯
Isn't there a folder like starterplayer? or does that put it inside a folder?
I really can't remember
nope
[PlayerAdded](player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
local val1 = Instance.new("NumberValue", folder)
val1.Name = "Foo"
val1.Value = 0
... -- Create other values
folder.Parent = player
end
or using roact
[PlayerAdded](player)
local tree = Roact.createElement("Folder", { Name = "leaderstats" }, {
Foo = Roact.createElement("NumberValue", {
Value = 0
}),
})
Roact.mount(tree, player, "leaderstats")
end
ok
Here is teh script that i am havign problems with btw: local DataStoreService = game:GetService("DataStoreService")
local PlayerStatsDS = DataStoreService:GetDataStore("CashSaveing_reset")
game.Players.PlayerAdded:Connect(function(NP)
local Key = "PDS-".. NP.UserId
local GetSave = PlayerStatsDS:GetAsync(Key)
local PSF = Instance.new("Folder", NP)
PSF.Name = "leaderstats"
local StatsFolder = script.Stats
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
if GetSave then
for n, Stat in pairs(PSF:GetChildren()) do
Stat.Value = GetSave[n]
end
else
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end
end)
game.Players.PlayerRemoving:connect(function(OP)
local Key = "PDS-".. OP.UserId
local StatsFolder = OP.leaderstats
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end)
i still does not work
** You are now Level 2! **
do you know how to fix the script? @vagrant hinge it wont work with the tycoon
local DataStoreService = game:GetService("DataStoreService")
local PlayerStatsDS = DataStoreService:GetDataStore("CashSaveingreset")
game.Players.PlayerAdded:Connect(function(NP)
local Key = "PDS-".. NP.UserId
local GetSave = PlayerStatsDS:GetAsync(Key)
local PSF = Instance.new("Folder", NP)
PSF.Name = "leaderstats"
local StatsFolder = script.Stats
for , S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
if GetSave then
for n, Stat in pairs(PSF:GetChildren()) do
Stat.Value = GetSave[n]
end
else
local STS = {}
for , Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end
end)
game.Players.PlayerRemoving:connect(function(OP)
local Key = "PDS-".. OP.UserId
local StatsFolder = OP.leaderstats
local STS = {}
for , Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
end
PlayerStatsDS:SetAsync(Key, STS)
end)
i still does not work
do you still have 2 leaderstats ?
no but when i buy a car it wont take away cash from my tycoon leaderstat
did you used a remote event ?
man remote event
Hey are you experienced with profilestores?
not really, ive heard about but i need to learn them
Oh yeah cuz I have a problem
and there is a cash in side the script. if that makes the problems idk
that wont work
if you want to use gui you have to use remote event
i see you dont want to deal with them but if you wanna learn scripting, you will have too since its super usefull and super important
what is it ?
dont forget to check the wiki maybe there are the awnser
when i try to access the profile Data (by doing profile.Data.Cash) it gives me an error "Attempt to index nil with data"
i checked on there no one said anything about it
checked on youtube no one said anything
checked on the devforum nothing there aswel
create a post in #1020374354867007528
maybe there are people that know alot about them and that can helps you
i did but it doesn't seem to be getting any attention
How do i put the script together with the remote event? I really dont know how to do this
havent saw lol
just wait some time
create a remote event in replicated storage, use Remoteevent.FireServer:Connect(function() in local script and do Remoteevent.OnServerEvent:Connect(function() on serverscript
- Create a remote event in ReplicatedStorage and give it a name ( for example
Toto) - In yout local script do :
local remoteEvent = assert([ReplicatedStorage]:FindFirstChild("Toto")) -- Search for your remote event
local data1 = "Any data you want, here its a string"
local data2 = 42 -- and here its a number
remoteEvent:FireServer(data1, data2) -- you can add as many stuff as you want
- Get the data from your server script
local remoteEvent = assert([ReplicatedStorage]:FindFirstChild("Toto")) -- Search for your remote event
local function ServerEvent(player, data1, data2)
print(player) -- The player who triggered it
print(data1) -- "Any data you want, here its a string"
print(data2) -- 42
end
remoteEvent.OnServerEvent:Connect(ServerEvent)
im pretty sure you can find a similar example in the documentation i give you -_-
I need the script to know what the name of the currency is