Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix the "Expected identifier when parsing method name, got "}"" error?

Hello, I am quite new to scripting so I apologize if this is a dumb question, I was wondering how to fix the error above, here's the code

wait()
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Tool = script.Parent
local Handle = 	Tool:WaitForChild("Handle")
local PlayingAnimation = nil

local Activated = false
local Equipred = false
local SrartTick = tick()
local CanUse = false

local ActiveTick = tick()

local mouse = Player:GetMouse()

local Animations = {
	Idle = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Idle")),
	    Duration:1.5,
	},
	Equip = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Equip")),
		Duration:0.7,
	},
		Stab1 = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Stab1")),
		Duration:0.8,
	},
		Stab2 = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Stab2")),
	    Duration:0.9,
	},
		ThrowHold = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("ThrowHold")).
	    
	},
		Throw = {
		Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Throw")),
	    
	},
}

Tool.Equipped:Connect(function()
	warn("Equipped")
	Equipred = true 
	PlayingAnimation = Animations.Equip
	PlayingAnimation.Animation:Play()
	StartTick = tick()
	repeat wait() until (tick)) - StartTick) >= PlayingAnimation.Duration
	PlayingAnimation.Animation:Stop()
	PlayingAnimation = Animations.idle
	PlayingAnimation.Animation:Play()
	CanUse = true
	warn ('AfterEquipped')
end)

2 answers

In a few of your dictionaries you define the value of Duration with a colon :. While in some languages this is proper dictionary syntax, in Lua dictionaries need equal signs = instead. Try changing all your Duration: 0.9, to Duration = 0.9, and etc.

Your script had a couple of syntax errors. Those have been fixed in the script along with some other things. Try this one out.

wait()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.Character:Wait() -- sometimes the script can load before the player does so I added onto that
local Tool = script.Parent
local Handle =  Tool:WaitForChild("Handle")
local PlayingAnimation = nil

local Activated = false
local Equipped = false -- small spelling mistake here, fixed
local StartTick = tick() -- and here
local CanUse = false

local ActiveTick = tick()

local mouse = Player:GetMouse()

local Animations = {
    Idle = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Idle")),
        Duration = 1.5, -- Like the previous answer said, Lua needs equal signs instead of colons
    },
    Equip = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Equip")),
        Duration = 0.7,
    },
        Stab1 = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Stab1")),
        Duration = 0.8,
    },
        Stab2 = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Stab2")),
        Duration = 0.9,
    },
        ThrowHold = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("ThrowHold")),

    },
        Throw = {
        Animation = Character.Humanoid:LoadAnimation(script.Parent:WaitForChild("Throw")),

    },
}


Tool.Equipped:Connect(function()
    print("Equipped") -- I recommend you to just use print() instead.
    Equipped = true 
    PlayingAnimation = Animations.Equip
    PlayingAnimation.Animation:Play()
    StartTick = tick() 
    repeat wait() until ((tick) - StartTick) >= PlayingAnimation.Duration
    PlayingAnimation.Animation:Stop()
    PlayingAnimation = Animations.idle
    PlayingAnimation.Animation:Play()
    CanUse = true
    print("AfterEquipped") 
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.