weapon script(on server):
local tween = game:GetService("TweenService")
local casting = false
local Debris = game:GetService("Debris")
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
if casting == true then return end
casting = true
local iceSpikes = game.ReplicatedStorage.IceSpikes:Clone()
local attackAnim = player.Character.Humanoid:LoadAnimation(script.Parent.Attack)
local IceSound = script.Parent["Ice 2 SFX"]
local TrailElecriticy = game.ServerStorage.TrailElectricity:Clone()
local TrailElecriticyBlur = game.ServerStorage.TrailElectricityBlur:Clone()
IceSound:Play()
attackAnim:Play()
iceSpikes:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame)
iceSpikes.Parent = workspace
local endPosition = {Position = {}, Orientation = {}}
for i, v in pairs(iceSpikes.Spikes:GetChildren()) do
endPosition["Position"][i] = v.Position
endPosition["Orientation"][i] = v.Orientation
v.CFrame = CFrame.new(iceSpikes.Origin.Position)
end
wait(0.4)
for i,v in pairs(iceSpikes.Spikes:GetChildren()) do
v.Orientation = endPosition["Orientation"][i]
tween:Create(v, TweenInfo.new(0.4),{Position = endPosition["Position"][i]}):Play()
end
for i,v in pairs(iceSpikes.Spikes:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("AlreadyHit") and not hit:IsDescendantOf(player.Character) then
local humanoid = player.Character:FindFirstChild("Humanoid")
local enemyHumanoid = hit.Parent:FindFirstChild("Humanoid")
local enemy = hit.Parent
local alreadyHit = Instance.new("BoolValue")
alreadyHit.Parent = hit.Parent
alreadyHit.Name = "AlreadyHit"
UntagHumanoid(humanoid)
TagHumanoid(humanoid,enemyHumanoid)
enemyHumanoid:TakeDamage(25)
game.ReplicatedStorage.Freeze:Fire(enemyHumanoid,enemy,TrailElecriticy,TrailElecriticyBlur,alreadyHit)
end
end)
end
wait(1.2)
iceSpikes:Destroy()
wait(5)
casting = false
end)
leaderstats(on server):
local dataStore = game:GetService("DataStoreService")
local KillStore = dataStore:GetDataStore("KillStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local kill = Instance.new("NumberValue")
kill.Name = "Kill"
kill.Value = 0
kill.Parent = leaderstats
player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function(Died)
local creator = Character.Humanoid:FindFirstChild("creator")
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator ~= nil and creator.Value ~= nil then
leaderstats.Kill.Value = leaderstats.Kill.Value + 1
end
end)
end)
local data
local success,errormessage = pcall(function()
data = KillStore:GetAsync(player.UserId.."-kill")
end)
if success then
kill.Value = data
else
print("There was an error while getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success,errormessage = pcall(function()
KillStore:SetAsync(player.UserId.."-kill",player.leaderstats.Kill.Value)
end)
if success then
print("player Data successfully saved!")
else
print("There was an error saving data")
warn(errormessage)
end
end)
error(on server):
ServerScriptService.leaderstats:16: attempt to index nil with 'Value'