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

help?: ServerScriptService.walksLeaderboard:71: Expected ')' (to close '(' at line 48), got 'end'

ERROR IS IN TITLE

local function equipPet(player,pet)
	

	
local character = player.Character
	
	if pet ~= nil and character ~= nil then
		
		if character:FindFirstChild(player.Name.."'s pet") then character [player.Name.."'s pet"]:Destroy() end
		if character.HumanoidRootPart:FindFirstChild("attachmentCharacter") then 
			character.HumanoidRootPart:FindFirstChild("attachmentCharacter"):Destroy() 
	    end
		
		pet.Name = player.Name.."'s name"
		
		pet:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame)
		
		local ModelSize = pet.PrimaryPart.Size
		
		local attachmentCharacter = Instance.new("Attachment")
		attachmentCharacter.Visible = false
		attachmentCharacter.Name = "attachmentCharacter"
		attachmentCharacter.Parent = character.HumanoidRootPart
		attachmentCharacter.Position = Vector3.new(1,1,0) + ModelSize
		
		local attachmentPet = Instance.new("Attachment")
		attachmentPet.Visible = false
		attachmentPet.Parent = pet.PrimaryPart
		
	    local alignPosition = Instance.new("AlignPosition")
	    alignPosition.MaxForce = 25000
		alignPosition.Attachment0 = attachmentPet
		alignPosition.Attachment1 = attachmentCharacter
		alignPosition.Responsiveness = 25
		alignPosition.Parent = pet
		
		local alignOrientation = Instance.new("AlignOrientation")
		alignOrientation.MaxTorque = 25000
		alignOrientation.Attachment0 = attachmentPet
		alignOrientation.Attachment1 = attachmentCharacter
		alignOrientation.Responsiveness = 25
		alignOrientation.Parent = pet
		
		pet.Parent = character
	end
	
end
	game.Players.PlayerAdded:Connect(function(player)  < --- error came from here
	local leaderstats = Instance.new('Folder') 
	leaderstats.Name = 'leaderstats'
	leaderstats.Parent = player
	

	local Walks = Instance.new('IntValue')
	Walks.Name = 'Walks'
	Walks.Value = 100000
	Walks.Parent = leaderstats
	
	local inventory = Instance.new("Folder")
	inventory.Name = "PetInventory"
	inventory.Parent = player
	
	local equippedPet = Instance.new("StringValue")
	equippedPet.Name = "EquippedPet"
	equippedPet.Parent = player
	
	player.CharacterAdded:Connect(function(Char)
		
		    end)
		 end
	 end)    < --- and here
end)

1 answer

✓ Accepted answer

You simply had one too many ends.

Change your script to this:

local function equipPet(player, pet)
    local character = player.Character

    if pet ~= nil and character ~= nil then
        if character:FindFirstChild(player.Name .. "'s pet") then
            character[player.Name .. "'s pet"]:Destroy()
        end
        if character.HumanoidRootPart:FindFirstChild("attachmentCharacter") then
            character.HumanoidRootPart:FindFirstChild("attachmentCharacter"):Destroy()
        end

        pet.Name = player.Name .. "'s name"

        pet:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame)

        local ModelSize = pet.PrimaryPart.Size

        local attachmentCharacter = Instance.new("Attachment")
        attachmentCharacter.Visible = false
        attachmentCharacter.Name = "attachmentCharacter"
        attachmentCharacter.Parent = character.HumanoidRootPart
        attachmentCharacter.Position = Vector3.new(1, 1, 0) + ModelSize

        local attachmentPet = Instance.new("Attachment")
        attachmentPet.Visible = false
        attachmentPet.Parent = pet.PrimaryPart

        local alignPosition = Instance.new("AlignPosition")
        alignPosition.MaxForce = 25000
        alignPosition.Attachment0 = attachmentPet
        alignPosition.Attachment1 = attachmentCharacter
        alignPosition.Responsiveness = 25
        alignPosition.Parent = pet

        local alignOrientation = Instance.new("AlignOrientation")
        alignOrientation.MaxTorque = 25000
        alignOrientation.Attachment0 = attachmentPet
        alignOrientation.Attachment1 = attachmentCharacter
        alignOrientation.Responsiveness = 25
        alignOrientation.Parent = pet

        pet.Parent = character
    end
end
game.Players.PlayerAdded:Connect(
    function(player) --- error came from here
        local leaderstats = Instance.new("Folder")
        leaderstats.Name = "leaderstats"
        leaderstats.Parent = player

        local Walks = Instance.new("IntValue")
        Walks.Name = "Walks"
        Walks.Value = 100000
        Walks.Parent = leaderstats

        local inventory = Instance.new("Folder")
        inventory.Name = "PetInventory"
        inventory.Parent = player

        local equippedPet = Instance.new("StringValue")
        equippedPet.Name = "EquippedPet"
        equippedPet.Parent = player

        player.CharacterAdded:Connect(
            function(Char)
            end
        ) --- and here
    end
)

2 comments

0

thx

0

i got another error while scripting:ServerScriptService.walksLeaderboard:76: Expected ')' (to close '(' at line 48), got 'end'

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