parts:WaitForChild("ProximityPrompt").Triggered:Connect(function(player)
local stop = false
for i,animations in pairs(player.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do
if animations.Name == "Swing1" or animations.Name == "Swing2" or animations.Name == "Swing3" then
stop = true
end
end
if player.Character:GetAttribute("Attacking") then stop = true end
if player.Character:GetAttribute("Stunned") then stop = true end
if stop then return end
PlayerDataService:Update(player, "CurrentTool", function(oldValue)
local newTool = parts:GetAttribute("GetTool")
--print("Retrieved new tool:", newTool)
return newTool
end)
--player.Character:SetAttribute("CurrentTool", parts:GetAttribute("GetTool"))
end)
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ProfileService = require(ServerScriptService.Modules.ProfileService)
local DataTemplate = require(script.DataTemplate)
local PlayerDataService = {}
local ProfileStore = ProfileService.GetProfileStore("Testing", DataTemplate)
local Profiles = {}
function CreateLeaderstats(player)
local playerData = Instance.new("Folder")
playerData.Name = "PlayerData"
playerData.Parent = player
player.Character:SetAttribute("CurrentTool", PlayerDataService:Get(player, "CurrentTool"))
player.Character:SetAttribute("CurrentWeapon", PlayerDataService:Get(player, "CurrentWeapon"))
end
function PlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if profile then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("something happened while loading your data just rejoin.")
end)
if not player:IsDescendantOf(Players) then
profile:Release()
else
Profiles[player] = profile
CreateLeaderstats(player)
end
else
player:Kick("something happened while loading your data just rejoin.")
end
end
function PlayerDataService.Start()
for _, player in game.Players:GetPlayers() do
task.spawn(PlayerAdded, player)
end
game.Players.PlayerAdded:Connect(function(player)
PlayerAdded(player)
end)
game.Players.PlayerRemoving:Connect(function(player)
if Profiles[player] then
Profiles[player]:Release()
end
end)
end
function getProfile(player)
assert(Profiles[player], string.format("Profile does not exist for %s", player.UserId))
return Profiles[player]
end
function PlayerDataService:Get(player, key)
local profile = getProfile(player)
assert(profile.Data[key], string.format("Data does not exist for %s", key))
return profile.Data[key]
end
function PlayerDataService:Set(player, key, value)
local profile = getProfile(player)
assert(profile.Data[key], string.format("Data does not exist for %s", key))
assert(type(profile.Data[key]) == type(value))
if player.Character:GetAttribute(key) then
player.Character:SetAttribute(key, value)
print(player.Character:GetAttribute(key))
print(PlayerDataService:Get(player, "CurrentTool"))
end
end
function PlayerDataService:Update(player, key, callback)
local profile = getProfile(player)
local oldData = self:Get(player, key)
local newData = callback(oldData)
self:Set(player, key, newData)
end
return PlayerDataService
local function ChangeTool(player, character, torso)
--character:SetAttribute("CurrentTool", PlayerDataService:Get(player, "CurrentTool"))
character:SetAttribute("ToolEquipped", false)
local currentTool = character:GetAttribute("CurrentTool")
local Tool = ToolModels[currentTool]:Clone()
Tool.Parent = character
Welds[player] = ToolWelds[currentTool].IdleToolWeld:Clone()
Welds[player].Parent = torso
Welds[player].Part0 = torso
Welds[player].Part1 = Tool
if Tool:FindFirstChild("SecondTool") then
Tool.SecondToolWeld.Part0 = character["Left Arm"]
Tool.SecondToolWeld.Part1 = Tool.SecondTool
end
if EquipAnimations[player] then EquipAnimations[player]:Stop() end
if IdleAnimations[player] then IdleAnimations[player]:Stop() end
if UnequipAnimations[player] then UnequipAnimations[player]:Stop() end
EquipDebounce[player] = false
character.Humanoid.WalkSpeed = StarterPlayer.CharacterWalkSpeed
character.Humanoid.JumpHeight = StarterPlayer.CharacterJumpHeight
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local torso = character.Torso
task.wait(3)
ChangeTool(player, character, torso)
character.Parent = workspace.Characters
character:GetAttributeChangedSignal("CurrentTool"):Connect(function()
for i, tools in pairs(ToolModels:GetChildren()) do
if character:FindFirstChild(tools.Name) then
character:FindFirstChild(tools.Name):Destroy()
end
end
ChangeTool(player, character, torso)
end)
end)
player.CharacterAppearanceLoaded:Connect(function(character)
for i,v in pairs(character:GetDescendants()) do
if v.Parent:IsA("Accessory") and v:IsA("Part") then
v.CanTouch = false
v.CanQuery = false
end
end
end)
end)
my CurrentTool should update and it just doesnt and idk why
where it prints Pickaxe it should be printing Axe but its just not changing for some reason