Next script error :D

hello there guys!
I have an error that just appeard
first animation dont want to show on all body next issue was not error that the gui show only for one person but its repaired with Chat GPT but animation still dont want to show on all body and AI just messed code up so please help?
here is code from tool (pssst do not ask for what is it):
– Pobierz model gracza
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local hum = player.Character:FindFirstChildOfClass(“Humanoid”)

– Pobierz animację
local animation = script.Parent.Animation

– Odtwórz animację na graczu
local animationTrack = character:FindFirstChild(“AnimationTrack”)
if not animationTrack then
animationTrack = character.Humanoid:LoadAnimation(animation)
animationTrack.WeightCurrent = 1 – Ustawienie właściwości WeightCurrent na 1, aby animacja była odtwarzana na całym ciele
end

– Zdalne zdarzenia na serwerze
local remoteEvent1 = game.ReplicatedStorage.re1 – ZAMIEŃ NA NAZWĘ PIERWSZEGO ZDARZENIA
local remoteEvent2 = game.ReplicatedStorage.re2 – ZAMIEŃ NA NAZWĘ DRUGIEGO ZDARZENIA

tool.Activated:Connect(function()
local random = math.random(1, 2)
if random == 1 then
animationTrack:Play()
remoteEvent1:FireServer() – Wysyła zdarzenie 1 na serwer
elseif random == 2 then
animationTrack:Play()
remoteEvent2:FireServer()
if hum then
hum.Health = 0
wait(2)
player:Kick(“You Died. To Play Again Just Join. Bullets are waiting”)
end
end
end)

And There some code from serverscriptservice:

local anywhere = game.ReplicatedStorage

local r1 = anywhere.re1 – ZAMIEŃ NA NAZWĘ PIERWSZEGO ZDARZENIA

local r2 = anywhere.re2 – ZAMIEŃ NA NAZWĘ DRUGIEGO ZDARZENIA

– Funkcja obsługująca zdarzenie 1 na serwerze

r1.OnServerEvent:Connect(function(player)

player.PlayerGui.ScreenGui.TextLabel.Visible = true

wait(2)

player.PlayerGui.ScreenGui.TextLabel.Visible = false

end)

– Funkcja obsługująca zdarzenie 2 na serwerze

r2.OnServerEvent:Connect(function(player)

player.PlayerGui.ScreenGui.Frame.Visible = true

wait(3)

player.PlayerGui.ScreenGui.Frame.Visible = false

end)

so if you can programing well yi=ou can help me? AI messed this up and its not even starting

so can you guys help?
this is main script to my game so if this dont gonna work
then game gonna doesn’t exist

Format it, I can’t even read it.

I didn’t use a translator for the comments, I just put in what I thought was right based on the code.

-- client:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local hum = player.Character.Humanoid
local animation = script.Parent.Animation

-- Create Animations
local animationTrack = character:FindFirstChild("AnimationTrack")
if not animationTrack then
    animationTrack = character.Humanoid:LoadAnimation(animation)
    animationTrack.WeightCurrent = 1 -- Ustawienie właściwości WeightCurrent na 1, aby animacja była odtwarzana na całym ciele
end

-- Remotes
local remoteEvent1 = game.ReplicatedStorage.re1
local remoteEvent2 = game.ReplicatedStorage.re2

tool.Activated:Connect(function()
    local random = math.random(1, 2)
    if random == 1 then
        animationTrack:Play()
        remoteEvent1:FireServer()
    else
        animationTrack:Play()
        remoteEvent2:FireServer()
        if hum then
            hum.Health = 0
            task.wait(2)
            player:Kick("You Died. To play again, rejoin. Bullets are waiting!")
        end
    end
end)
-- server:

local remoteEvent1 = game.ReplicatedStorage.re1
local remoteEvent2 = game.ReplicatedStorage.re2

remoteEvent1.OnServerEvent:Connect(function(player)
    player.PlayerGui.ScreenGui.TextLabel.Visible = true
    task.wait(2)
    player.PlayerGui.ScreenGui.TextLabel.Visible = false
end)

remoteEvent2.OnServerEvent:Connect(function(player)
    player.PlayerGui.ScreenGui.Frame.Visible = true
    task.wait(3)
    player.PlayerGui.ScreenGui.Frame.Visible = false
end)

I’d say the remotes are quite useless if all they do is modify UI, which the client could have just done itself. It would help if you showed us what the error was.

Summary

Powiedziałbym, że piloty są całkowicie bezużyteczne, jeśli jedyne, co robią, to modyfikują interfejs użytkownika, co lokalny skrypt mógłby zrobić sam. Pomogłoby, gdybyś mógł nam pokazać, jaki był błąd.

You are not loading the animation on a animator, you’re trying to load on humanoid. Load a animation instance on animator then it will return a track.

And you don’t need to set Track weight

And I think you are killing Humanoid so fast to it play the animation, no?

This is kind of unrelated. But for security purposes, you should not kill the player, and kick them, etc on the client. Local scripts can be tampered with by exploiters. Make sure the server does all these things. (Use RemoteEvents)

thanks dude yeah propably humanoid kill is too speed
but thanks

okay so i supposed to do remote event for kick?

i need it because it’s suppused to show gui for all players not just for user of the tool

Yes. But not just for kicking, also for killing the player, calculating the chance in the first place (math.random()).

Basically, anything that has to do with actual functionality should be done on the server, while visual things should be done on the client.

okay dude thanks for security my game