so i have been scripting for 2 weeks and my tool isnt working in game but it is in studio also can i get help adding animation?
LeaderStats Code Its Supposed To Save Data This is normal script
local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("myDataStore") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local Muscle = Instance.new("IntValue") Muscle.Name = "Muscle" Muscle.Parent = leaderstats local data local success, errormessage = pcall(function() myDataStore:GetAsyn(player.UserId.. "-Muscle") end) if success then Muscle.Value = data else print("There Was A Error Saving Your Data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-Muscle",player.leaderstats.Muscle.Value) end) if success then print("Player Data Is Saved :D") else print("There Was An Error Saving Data") warn(errormessage) end end)
and here is my tools code this is local script
script.Parent.Activated:Connect(function() local plr = game.Players:FindFirstChild(script.Parent.Parent.Name) if plr then local stats = plr:WaitForChild("leaderstats") local Muscle = stats:WaitForChild("Muscle") Muscle.Value = Muscle.Value + 1 end end)
You would have to use remote events to pass from the client to the server, a server script cannot detect changes made by a local script
edit: Also you spelled Async wrong in the "GetAsync" function
The issue is due to the fact that you're changing the values on the client. Because of filtering enabled, it prevents changes on the client to replicate to the server.
In this case, you can change the script to a server script without having to change any of the code and it will still work. If there are other things depending on the local player in your script where changing it to a server script will break it, then you can also use a Remote Event as an alternative solution.
The problem is exactly because you're doing it in a local script. Local scripts only change the information for that person in particular, in order for it to be changed to everyone you'll need to do it in a server script.
To fix this particular case you'll need to add a "RemoteEvent" into the replicated storage. After that you'll (inside of the local script) do RemoteEvent:FireServer(1) and now on a server script you'll add the event to listen to this request and add the muscle points there.
I highly recommend you to read this in order to understand on how it works: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events