Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Can I Fix This Script To Load My Animations In A Group Game?

Asked by 5 years ago

I have a very interesting situation, i'm working on a simple GROUP game that should only need 2 animations one for a garden hoe and one for an axe. My problem is the code below:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local debounce = false
local char = game.Workspace:WaitForChild(player.Name)
local hum = char:WaitForChild("Humanoid")local Tool = script.Parent


local SlashAnim = Instance.new("Animation")
SlashAnim.Name = "toolanim"
SlashAnim.AnimationId = "http://www.roblox.com/asset/?id=2018877217" 
SlashAnim.Parent = Tool
SlashAnimLoaded = hum:LoadAnimation(SlashAnim)

script.Parent.TextButton.MouseButton1Down:Connect(function()
    if not debounce then
        debounce = true
        SlashAnimLoaded:Play()
        wait(0.9)
        debounce = false
    end
end)

This code should be straight forward and it works in when i click Play but when in a server it prints this error:

https://pasteboard.co/Hsb0ayA.png

This makes no sense and i have tried even more to fix this. I tried pasting and making the necessary changes to detect when a button in a GUI is clicked and it created the same output as above. I have tried using a game created by me, not a group, same result.

I did notice something though and it appears that my tools don't want to cooperate with my animations. I was playing in "Play" mode in studio and had the text button to play the animation. The GUI Text Button loaded the animation with no tool equipped but when i tried literally the same script IN the tool, nothing happened. Someone please help my get my animations to load into my game without this error.

1 answer

Log in to vote
0
Answered by 5 years ago

Sry i posted the wrong code here is the correct code inside my tool:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local debounce = false
local char = game.Workspace:WaitForChild(player.Name)
local hum = char:WaitForChild("Humanoid")local Tool = script.Parent


local SlashAnim = Instance.new("Animation")
SlashAnim.Name = "toolanim"
SlashAnim.AnimationId = "http://www.roblox.com/asset/?id=1928807089" 
SlashAnim.Parent = Tool
SlashAnimLoaded = hum:LoadAnimation(SlashAnim)

script.Parent.Activated:Connect(function()
    if not debounce then
        debounce = true
        SlashAnimLoaded:Play()
        wait(0.9)
        debounce = false
    end
end)

script.Parent.Unequipped:Connect(function()
    SlashAnimLoaded:Stop()
end)

There is the code inside the tool

Ad

Answer this question